Edge Grid PHP

Akamai OPEN EdgeGrid for PHP Now in Beta

February 3, 2017 · by Davey Shafik

We are proud to release the first beta of both our PHP Signing library and HTTP client.

The signing library allows you to authenticate and digitally sign all requests made to the Akamai OPEN APIs.

Starting with our first release, based on the excellent Guzzle Http Client for PHP, we have added many features to improve your experience for writing API clients, including:

  • PSR-3 Compatible Logging
  • Verbose and Debug Handlers
  • PSR-7 HTTP Messages Support
  • An httpie-compatible Command Line Interface
  • Separated the signer from the client to support PHP 5.3+
  • Support for PHP 7.1 (for both)
  • Support for Environment Variable configuration

Additionally, we now have continuous integration tests running on PHP versions from 5.3+, including nightly builds and HHVM, on both Linux and Windows, totaling 60 builds for every commit.

The signer, akamai-open/edgegrid-auth, and the HTTP client akamai-open/edgegrid-client, 1.0.0beta1, are both available from Packagist via Composer, or as PHAR packages from their respective releases pages.


Using the HTTP Client

The HTTP client allows you to transparently authenticate all requests made to OPEN APIs automatically, and inherits from Guzzles a fully-featured HTTP client able to send GET/POST/PUT/HEAD/DELETE and other types of HTTP requests, to both Akamai OPEN APIs and any other HTTP endpoint.

Both packages are available to install using [composer](], simply run one of the following commands:

  • composer require akamai-open/edgegrid-client
  • composer require akamai-open/edgegrid-auth


To use the PHP client, you may call one of the factory methods:

  • \Akamai\Open\EdgeGrid\Client::createInstance() - create using the environment, or .edgerc file automatically
  • \Akamai\Open\EdgeGrid\Client::createFromEdgeRc() - create using an .edgerc file only
  • \Akamai\Open\EdgeGrid\Client::createFromEnv() - create using environment variables only


Alternatively, you can instantiate an instance identically to \GuzzleHttp\Client and call ->setAuth() instead:

$client = new Akamai\Open\EdgeGrid\Client([ 'base_uri' => '' ]);

$client->setAuth($client_token, $client_secret, $access_token);

Once you have your client, you can make calls using relative URLs using the appropriate HTTP method:

$response = $client->get('/diagnostic-tools/v1/locations'); if ($response) { $result = json_decode($response->getBody()); }


Or to POST a CCUv3 purge request:

$purge_body = [ 'hostname' => $hostname, 'objects' => ['/index.html', '/assets/img/splash.jpg', '/css/styles.css'] ];


$response = $this->client->post('/ccu/v3/invalidate/url', [ 'body' => json_encode($purge_body), 'headers' => ['Content-Type' => 'application/json'] ]);


Developer Experience

One of our primary concerns throughout this project has been ensuring a good developer experience. This is the primary reason we chose GuzzleHttp, arguably the most popular PHP HTTP client as our base, as well as making them installable using the defacto standard package manager: composer.

It's also why we have two middleware handlers to assist in debugging:

The verbose handler will route response bodies to STDOUT while the debug handler will route errors to STDERR. Both allow you to easily route their output to a log file (or any valid PHP stream) instead.


No Client Left Behind

We understand that not all customers can run the latest and greatest versions of PHP (however: PHP 5.5 has been been end-of-life since July 2016, and the more popular PHP 5.3 has been EOL for almost two and a half years!) which is why we provide the signer separately as a PHP 5.3+ compatible package.

We also recognize that not everybody can use composer, so both packages are available as a PHP Archive (PHAR) package, for easy uploading and inclusion in your code.

Whatever route you use to install and use these packages, we hope that you find the experience to be simple, and easy.


Thank You

At Akamai we track an incredible amount of data about everything happening on our platform, and the amount of growth in usage of our PHP libraries has been astounding. With that in mind, I just wanted to say "Thank You!", and to ensure you understand our commitment to PHP, and it's community.


Get Started

If you are using PHP and have yet to start using our libraries, you should check them out today:

If you have any questions, don't hesistate to reach out to our Developer Relations team,, or submit a post in Akamai Community.