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;
}Note
The Fastly API requires an API token for most operations.
Set up the API token 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.
Table of API endpoints
The fastly-php API client currently does not support the following endpoints:
/alerts/definitions/{definition_id}(DELETE, GET, PUT)/alerts/definitions(GET, POST)/alerts/history(GET)/dns/configurations/{dns_configuration_id}(DELETE, GET, PATCH)/dns/configurations(GET, POST)/domain-management/v1/domains/{domain_id}(DELETE, GET, PATCH)/domain-management/v1/domains(GET, POST)/domains/v1/tools/status(GET)/domains/v1/tools/suggest(GET)/ngwaf/v1/lists/{listId}(DELETE, GET, PATCH)/ngwaf/v1/lists(GET, POST)/ngwaf/v1/signals/{signal_id}(DELETE, GET, PATCH)/ngwaf/v1/signals(GET, POST)/ngwaf/v1/timeseries(GET)/ngwaf/v1/workspaces/{workspaceId}/lists/{listId}(DELETE, GET, PATCH)/ngwaf/v1/workspaces/{workspaceId}/lists(GET, POST)/ngwaf/v1/workspaces/{workspace_id}/alerts/{alert_id}/signing-key(GET, POST)/ngwaf/v1/workspaces/{workspace_id}/alerts/{alert_id}(DELETE, GET, PATCH)/ngwaf/v1/workspaces/{workspace_id}/alerts(GET, POST)/ngwaf/v1/workspaces/{workspace_id}/events/{event_id}(GET, PATCH)/ngwaf/v1/workspaces/{workspace_id}/events(GET)/ngwaf/v1/workspaces/{workspace_id}/redactions/{redaction_id}(DELETE, GET, PATCH)/ngwaf/v1/workspaces/{workspace_id}/redactions(GET, POST)/ngwaf/v1/workspaces/{workspace_id}/requests/{request_id}(GET)/ngwaf/v1/workspaces/{workspace_id}/requests(GET)/ngwaf/v1/workspaces/{workspace_id}/rules/{rule_id}(DELETE, GET, PATCH)/ngwaf/v1/workspaces/{workspace_id}/rules(GET, POST)/ngwaf/v1/workspaces/{workspace_id}/timeseries(GET)/ngwaf/v1/workspaces/{workspace_id}/virtual-patches/{virtual_patch_id}(GET, PATCH)/ngwaf/v1/workspaces/{workspace_id}/virtual-patches(GET)/ngwaf/v1/workspaces/{workspace_id}(DELETE, GET, PATCH)/ngwaf/v1/workspaces(GET, POST)/notifications/integration-types(GET)/notifications/integrations/{integration_id}/rotateSigningKey(POST)/notifications/integrations/{integration_id}/signingKey(GET)/notifications/integrations/{integration_id}(DELETE, GET, PATCH)/notifications/integrations(GET, POST)/notifications/mailinglist-confirmations(POST)/observability/timeseries(GET)/observability/timeseries(GET)/resources/stores/kv/{store_id}/batch(PUT)/security/workspaces/{workspace_id}/events/{event_id}(GET, PATCH)/security/workspaces/{workspace_id}/events(GET)/security/workspaces/{workspace_id}/redactions/{redaction_id}(DELETE, GET, PATCH)/security/workspaces/{workspace_id}/redactions(GET, POST)/security/workspaces/{workspace_id}/requests/{request_id}(GET)/security/workspaces/{workspace_id}/requests(GET)/security/workspaces/{workspace_id}/rules/{rule_id}(DELETE, GET, PATCH)/security/workspaces/{workspace_id}/rules(GET, POST)/security/workspaces/{workspace_id}/timeseries(GET)/security/workspaces/{workspace_id}/virtual-patches/{virtual_patch_id}(GET, PATCH)/security/workspaces/{workspace_id}/virtual-patches(GET)/security/workspaces/{workspace_id}(DELETE, GET, PATCH)/security/workspaces(GET, POST)/tls/activations/{tls_activation_id}(GET, PATCH)/tls/activations(GET)/tls/configurations/{tls_configuration_id}(DELETE, GET, PATCH)/tls/configurations(GET, POST)/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.