platformsh/client
PHP client library for the Platform.sh API. Authenticate with an API token, then manage projects, environments, and activities (e.g., branch operations) and create subscriptions. Used by the Platform.sh CLI; supports PHP 8.2+ in v3.
Pros:
runOperation), which can be mapped to Laravel’s queues/jobs for long-running tasks (e.g., deployments, builds).Cons:
3.x, which may necessitate Laravel 9+/10+ adoption if not already using it..env, using Vault, or Platform.sh’s built-in secrets) is critical.PlatformShService) to abstract Platform.sh operations.php artisan platformsh:deploy).3.x. If using Laravel <9, upgrade or use 2.x (deprecated).// app/Facades/PlatformSh.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class PlatformSh extends Facade {
protected static function getFacadeAccessor() { return 'platformsh.client'; }
}
3.x (PHP 8.2+).2.x (PHP 7.4+) with deprecation warnings.1.x is unsupported and uses outdated Guzzle 5.api_url is configured correctly.composer require platformsh/client.AppServiceProvider).
$this->app->singleton('platformsh.client', function () {
$connector = new Connector([
'api_url' => config('services.platformsh.api_url'),
'centralized_permissions_enabled' => true,
]);
$client = new PlatformClient();
$client->getConnector()->setApiToken(config('services.platformsh.token'), 'default');
return $client;
});
App/Services/PlatformShService) to wrap client operations.public function getProject(string $projectId): ?Project {
return $this->client->getProject($projectId);
}
PlatformSh::environment()->deploy()).Cache::remember).Mockery or createMock).$mockClient = $this->createMock(PlatformClient::class);
$mockClient->method('getProject')->willReturn($project);
$this->app->instance('platformsh.client', $mockClient);
Log facade).composer.json to avoid unexpected updates:
"require": {
"platformsh/client": "^3.0"
}
2.x, plan a migration to 3.x before PHP 7.4 support ends (likely 2024).$connector->setDebug(true);
How can I help you explore Laravel packages today?