This is a PHP library for accessing the Platform.sh API.
We recommend you use the Platform.sh CLI (which uses this library) for most purposes.
composer require platformsh/client
Example:
use Platformsh\Client\PlatformClient;
// Initialize the client.
$client = new PlatformClient();
// Set the API token to use.
//
// N.B. you must keep your API token(s) safe!
$client->getConnector()->setApiToken($myToken, 'exchange');
// Get the user's first project.
$projects = $client->getProjects();
$project = reset($projects);
if ($project) {
// Get the default (production) environment.
$environment = $project->getEnvironment($project->default_branch);
// Create a new branch.
$activity = $environment->branch('Sprint 1', 'sprint-1');
// Wait for the activity to complete.
$activity->wait();
// Get the new branch.
$sprint1 = $project->getEnvironment('sprint-1');
}