Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
ecrisostomo edited this page Sep 6, 2012 · 24 revisions

Stormpath PHP SDK

The Stormpath PHP SDK allows any PHP-based application to easily use the Stormpath cloud Identity Management service for all authentication and access control needs.

When you make SDK method calls, the calls are translated into HTTPS requests to the Stormpath REST+JSON API. The Stormpath PHP SDK therefore provides a clean object-oriented paradigm and alleviates the need to know how to make REST+JSON requests.

This SDK was implemented based on the 5.3.10 version of PHP.

Usage

  1. Follow the installation/configuration directions located on the README.md file.

  2. Ensure you have an API Key so your application can communicate with Stormpath. Store your API Key file somewhere secure (readable only by you), for example:

     /home/myhomedir/.stormpath/apiKey.properties
    

    This file's contents should contain the following name/value pairs (using your own values of course) in YAML-compliant format:

     $ cat /home/myhomedir/.stormpath/apiKey.properties
     
     apiKey.id : YOURAPIKEYIDHEREREPLACEME
     apiKey.secret : YoUrReAlLyLongSecretValueHereReplaceMeWithYourValue
    

    A lot more information on different ways to configure and retrieve information from this file can be found in the Client Builder API documentation.

    Also change the file permissions to ensure only you can read the file:

     $ chmod go-rw /home/myhomedir/.stormpath/apiKey.properties
    
  3. Configure your application to create a Stormpath SDK Client instance based on your API Key. The Client instance is your starting point for all operations with the Stormpath service. For example:

     $path = /path/to/your/apiKey.properties;
     $builder = new Services_Stormpath_Client_ClientBuilder;
     $client = $builder->setApiKeyFileLocation($path)->build(); 
    
  4. Use the Client instance to interact with your tenant data, such as Applications, Directories, and Accounts:

     $tenant = $client->getCurrentTenant();
     
     $applications = $tenant->getApplications();
     
     foreach ($applications as $application) {
        echo 'Application ' . $application->getName();
     }
     
     $directories = $tenant->getDirectories();
     
     foreach ($directories as $directory) {
         echo 'Directory ' . $directory->getName();
     }
    
Clone this wiki locally