https://github.com/typhonius/acquia-php-sdk-v2
A PHP SDK for Acquia Cloud API v2 https://cloud.acquia.com/api-docs/#
https://github.com/typhonius/acquia-php-sdk-v2
acquia acquia-api api cloud-api php php-sdk sdk
Last synced: 9 months ago
JSON representation
A PHP SDK for Acquia Cloud API v2 https://cloud.acquia.com/api-docs/#
- Host: GitHub
- URL: https://github.com/typhonius/acquia-php-sdk-v2
- Owner: typhonius
- License: mit
- Created: 2017-10-27T08:20:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-31T21:16:57.000Z (9 months ago)
- Last Synced: 2025-04-01T22:14:50.720Z (9 months ago)
- Topics: acquia, acquia-api, api, cloud-api, php, php-sdk, sdk
- Language: PHP
- Size: 2.14 MB
- Stars: 23
- Watchers: 4
- Forks: 21
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Acquia PHP SDK for CloudAPI v2
=
[](https://github.com/typhonius/acquia-php-sdk-v2/actions/workflows/php.yml)
[](https://packagist.org/packages/typhonius/acquia-php-sdk-v2)
[](https://codecov.io/gh/typhonius/acquia-php-sdk-v2)
[](https://scrutinizer-ci.com/g/typhonius/acquia-php-sdk-v2/)
[](https://dashboard.stryker-mutator.io/reports/github.com/typhonius/acquia-php-sdk-v2/master)
[](https://www.versioneye.com/user/projects/5a18bd670fb24f2125873c86#tab-dependencies)
[](https://packagist.org/packages/typhonius/acquia-php-sdk-v2)
[](https://packagist.org/packages/typhonius/acquia-php-sdk-v2)
This library provides the capability to develop tooling which integrates with the [new version (2.0) of Cloud API](https://cloud.acquia.com/api-docs/).
The [original Acquia Cloud SDK](https://github.com/acquia/acquia-sdk-php) has been deprecated so build tools requiring modern PHP versions and packages should use this library.
## Installation
The SDK can be installed with [Composer](http://getcomposer.org) by adding this
library as a dependency to your composer.json file.
```json
{
"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
$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](https://typhonius.github.io/acquia-php-sdk-v2/).
## I just want to talk to the API without having to write code
The [Acquia Cli Robo application](https://github.com/typhonius/acquia_cli) 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.