Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.14 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.14 KB

Platform.sh API client

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.

Build Status

Install

composer require platformsh/client

Usage

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');
}