A PHP client library for interacting with most facets of the Fastly API.
Requires PHP 7.3 or later.
To install via Composer, add the following to your project's composer.json:
{
"require": {
"fastly/fastly": "*@dev"
}
}Then run composer install.
Composer generates a vendor/autoload.php file. You can include this file and start using the classes provided by this client without any extra work:
<?php
require_once('/path/to/project/vendor/autoload.php');<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Authorize the client with a Fastly API token.
$config = Fastly\Configuration::getDefaultConfiguration()->setApiToken('YOUR_API_TOKEN');
// Alternatively, set the FASTLY_API_TOKEN environment variable:
// $config = Fastly\Configuration::getDefaultConfiguration();
$apiInstance = new Fastly\Api\(
// Optionally, pass a custom client that implements `GuzzleHttp\ClientInterface`.
// `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$options['service_id'] = 'SU1Z0isxPaozGVKXdv0eY'; // string
$options['version_id'] = 56; // int
$options['name'] = 'my_acl'; // string
try {
$result = $apiInstance->createAcl($options);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AclApi->createAcl: ', $e->getMessage(), PHP_EOL;
}The Fastly API requires an API token for most operations. Set it in the PHP client by using the setApiToken method of a configuration as shown:
Fastly\Configuration::getDefaultConfiguration()->setApiToken('YOUR_API_TOKEN');Alternatively, set the FASTLY_API_TOKEN environment variable instead of using setApiToken.
Fastly\Configuration::getDefaultConfiguration();The main documentation for the Fastly API can be found on our Developer Hub.
The fastly-php API client currently does not support the following endpoints:
/resources/stores/kv/{store_id}/batch(PUT)/tls/activations/{tls_activation_id}(GET, PATCH)/tls/activations(GET)/v1/channel/{service_id}/ts/h/limit/{max_entries}(GET)/v1/channel/{service_id}/ts/h(GET)/v1/channel/{service_id}/ts/{start_timestamp}(GET)
If you encounter any non-security-related bug or unexpected behavior, please file an issue using the bug report template.
Please see our SECURITY.md for guidance on reporting security-related issues.
MIT.