typhonius / acquia-php-sdk-v2
A PHP SDK for Acquia CloudAPI v2
Fund package maintenance!
typhonius
Installs: 2 250 855
Dependents: 9
Suggesters: 0
Security: 0
Stars: 23
Watchers: 6
Forks: 21
Open Issues: 4
Requires
- php: ^8.0 | ^8.1 | ^8.2
- guzzlehttp/guzzle: ^7.2
- league/oauth2-client: ^2.4
- symfony/cache: ^5 | ^6 | ^7
- symfony/filesystem: ^5.4 | ^6 | ^7
Requires (Dev)
- ext-json: *
- eloquent/phony: dev-main as 5.0.2
- eloquent/phony-phpunit: ^7
- overtrue/phplint: ^9
- php-coveralls/php-coveralls: ^2.0.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9
- slevomat/coding-standard: ^8.4
- squizlabs/php_codesniffer: ^3.9.1
- dev-master
- 3.4.0
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.x-dev
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/dependencies-eec8771d2b
- dev-danepowell-patch-2
- dev-danepowell-patch-1
- dev-grasmash-patch-1
- dev-add-linked-resources
This package is auto-updated.
Last update: 2024-11-19 20:58:22 UTC
README
This library provides the capability to develop tooling which integrates with the new version (2.0) of Cloud API.
The original Acquia Cloud SDK has been deprecated so build tools requiring modern PHP versions and packages should use this library.
Installation
The SDK can be installed with Composer by adding this library as a dependency to your composer.json file.
{ "require": { "typhonius/acquia-php-sdk-v2": "^2" } }
Generating an API access token
To generate an API access token, login to https://cloud.acquia.com, then visit https://cloud.acquia.com/#/profile/tokens, and click Create Token.
- Provide a label for the access token, so it can be easily identified. Click Create Token.
- The token has been generated, copy the api key and api secret to a secure place. Make sure you record it now: you will not be able to retrieve this access token's secret again.
Usage
Basic usage examples for the SDK.
<?php require 'vendor/autoload.php'; use AcquiaCloudApi\Connector\Client; use AcquiaCloudApi\Connector\Connector; use AcquiaCloudApi\Endpoints\Applications; use AcquiaCloudApi\Endpoints\Environments; use AcquiaCloudApi\Endpoints\Servers; use AcquiaCloudApi\Endpoints\DatabaseBackups; use AcquiaCloudApi\Endpoints\Variables; use AcquiaCloudApi\Endpoints\Account; $key = 'd0697bfc-7f56-4942-9205-b5686bf5b3f5'; $secret = 'D5UfO/4FfNBWn4+0cUwpLOoFzfP7Qqib4AoY+wYGsKE='; $config = [ 'key' => $key, 'secret' => $secret, ]; $connector = new Connector($config); $client = Client::factory($connector); $application = new Applications($client); $environment = new Environments($client); $server = new Servers($client); $backup = new DatabaseBackups($client); $variable = new Variables($client); $account = new Account($client); // Get all applications. $applications = $application->getAll(); // Get all environments of an application. $environments = $environment->getAll($applicationUuid); // Get all servers in an environment. $servers = $server->getAll($environmentUuid); // Create DB backup $backup->create($environmentUuid, $dbName); // Set an environment varible $variable->create($environmentUuid, 'test_variable', 'test_value'); // Download Drush 9 aliases to a temp directory $client->addQuery('version', '9'); $result = $account->getDrushAliases(); $drushArchive = tempnam(sys_get_temp_dir(), 'AcquiaDrushAliases') . '.tar.gz'; file_put_contents($drushArchive, $aliases, LOCK_EX); // Download database backup // file_put_contents loads the response into memory. This is okay for small things like Drush aliases, but not for database backups. // Use curl.options to stream data to disk and minimize memory usage. $client->addOption('sink', $filepath); $client->addOption('curl.options', ['CURLOPT_RETURNTRANSFER' => true, 'CURLOPT_FILE' => $filepath]); $backup->download($environmentUuid, $dbName, $backupId);
Documentation
Documentation of each of the classes and methods has been automatically generated by phpDocumentor and exists in the gh-pages
branch. This is available for browsing on GitHub.
I just want to talk to the API without having to write code
The Acquia Cli Robo application creates a command line tool for communicating with the API using this SDK. Its purpose is to provide a simple mechanism for interacting with the API without having to write a line of code.