platformsh/client API client

2.5.1 2021-10-20 20:22 UTC

This package is auto-updated.

Last update: 2022-05-25 18:11:53 UTC


This is a PHP library for accessing the API.

We recommend you use the CLI (which uses this library) for most purposes.

Build Status


  • The 2.x branch (major version 2) requires PHP 7.1.0 and above.
  • The 1.x branch (any version < 2) supports PHP 5.5.9 and above, and uses Guzzle 5. Old PHP versions are supported by the CLI, which is why this branch is still maintained.


composer require platformsh/client



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.

    // Get the new branch.
    $sprint1 = $project->getEnvironment('sprint-1');

Creating a project:

use \Platformsh\Client\Model\Subscription\SubscriptionOptions;

$subscription = $client->createSubscription(SubscriptionOptions::fromArray([
    'project_region' => '',
    'project_title' => 'My project',
    'plan' => 'development',
    'default_branch' => 'main',

echo "Created subscription $subscription->id, waiting for it to activate...\n";


$project = $subscription->getProject();

echo "The project is now active: $project->id\n";
echo "Git URI: " . $project->getGitUrl() . "\n";