{"id":22394328,"url":"https://github.com/akamai/akamaiopen-edgegrid-php-client","last_synced_at":"2025-04-12T10:56:38.332Z","repository":{"id":23596724,"uuid":"26965459","full_name":"akamai/AkamaiOPEN-edgegrid-php-client","owner":"akamai","description":"PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)","archived":false,"fork":false,"pushed_at":"2025-03-25T09:47:13.000Z","size":1305,"stargazers_count":47,"open_issues_count":0,"forks_count":59,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-05T08:06:29.682Z","etag":null,"topics":["akamai","akamai-devexp","authentication","client","edgegrid","edgegrid-client","guzzle","middleware","open","php","php-library"],"latest_commit_sha":null,"homepage":"https://techdocs.akamai.com/home","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akamai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-11-21T15:31:02.000Z","updated_at":"2025-03-25T09:41:56.000Z","dependencies_parsed_at":"2023-10-20T16:28:51.208Z","dependency_job_id":null,"html_url":"https://github.com/akamai/AkamaiOPEN-edgegrid-php-client","commit_stats":{"total_commits":160,"total_committers":10,"mean_commits":16.0,"dds":0.5,"last_synced_commit":"3056a87bc4fa9c8e3bacdb9cfe67958c88eb1b3b"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamai%2FAkamaiOPEN-edgegrid-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamai%2FAkamaiOPEN-edgegrid-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamai%2FAkamaiOPEN-edgegrid-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamai%2FAkamaiOPEN-edgegrid-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akamai","download_url":"https://codeload.github.com/akamai/AkamaiOPEN-edgegrid-php-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248557830,"owners_count":21124165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akamai","akamai-devexp","authentication","client","edgegrid","edgegrid-client","guzzle","middleware","open","php","php-library"],"created_at":"2024-12-05T05:09:44.388Z","updated_at":"2025-04-12T10:56:38.294Z","avatar_url":"https://github.com/akamai.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# akamai-open/edgegrid-client\n\n[Akamai EdgeGrid Authentication](https://techdocs.akamai.com/developer/docs/set-up-authentication-credentials) for PHP.\n\nThis library requires PHP 8+ and implements the Akamai EdgeGrid Authentication scheme on top of [Guzzle](https://github.com/guzzle/guzzle) as both a drop-in replacement client and middleware.\n\n## Installation\n\nTo install, use [`composer`](http://getcomposer.org):\n\n```sh\n$ composer require akamai-open/edgegrid-client\n```\n\n### Alternative installation method\n\nDownload the PHAR file from the [releases](https://github.com/akamai/AkamaiOPEN-edgegrid-php/releases) page and include it inside your code:\n\n```php\ninclude 'akamai-open-edgegrid-auth.phar';\n\n// Library is ready to use\n```\n\n## Authentication\n\nYou can obtain the authentication credentials through an API client. Requests to the API are marked with a timestamp and a signature and are executed immediately.\n\n1. [Create authentication credentials](https://techdocs.akamai.com/developer/docs/set-up-authentication-credentials).\n\n2. Place your credentials in an EdgeGrid file `~/.edgerc`, in the `[default]` section.\n\n    ```\n    [default]\n    client_secret = C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=\n    host = akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net\n    access_token = akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij\n    client_token = akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj\n    ```\n\n3. Use your local `.edgerc` by providing credentials' section header and the path to your resource file. You can call your `.edgerc` file using the `\\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile()` method.\n\n    The location of your `.edgerc` file is optional, as it defaults to `~/.edgerc`.\n\n    ```php\n    $client = \\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile('{credentials_section_name}', '{path/to/.edgerc}');\n\n    // Use $client just as you would \\Guzzle\\Http\\Client\n    $response = $client-\u003eget('/identity-management/v3/user-profile');\n    ```\n\n    Alternatively, you can hard code your credentials by passing the credential values to the `\\Akamai\\Open\\EdgeGrid\\Client-\u003esetAuth()` method.\n\n    ```php\n    $client = new Akamai\\Open\\EdgeGrid\\Client([\n    'base_uri' =\u003e 'https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net'\n    ]);\n\n    $client_token = 'akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj';\n    $client_secret = 'C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=';\n    $access_token = 'akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij';\n\n    $client-\u003esetAuth($client_token, $client_secret, $access_token);\n\n    // use $client just as you would \\Guzzle\\Http\\Client\n    $response = $client-\u003eget('/identity-management/v3/user-profile');\n    ```\n\n## Use\n\nThe `Akamai\\Open\\EdgeGrid\\Client` extends `\\GuzzleHttp\\Client` as a drop-in replacement. It works transparently to sign API requests without changing other ways you use Guzzle.\n\nInclude the autoloader to import all the required classes.\n\nProvide your credentials section header and appropriate endpoint information.\n\n```php\n\u003c?php\nrequire \"vendor/autoload.php\";\n\n$client = \\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile('default');\n\n// use $client just as you would \\Guzzle\\Http\\Client\n$response = $client-\u003eget('/identity-management/v3/user-profile');\n\necho $response-\u003egetBody();\n```\n\n### Query string parameters\n\nYou can pass the query parameters in the url after a question mark (\"?\") at the end of the main URL path.\n\n```php\n\u003c?php\nrequire \"vendor/autoload.php\";\n\n$client = \\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile('default');\n\n$headers = [\n'Accept' =\u003e 'application/json',\n];\n\n$response = $client-\u003eget('/identity-management/v3/user-profile?authGrants=true\u0026notifications=true\u0026actions=true', $headers);\n\necho $response-\u003egetBody();\n```\n\nYou can also pass the query parameters using a `query` request option. See the [Guzzle documentation](https://docs.guzzlephp.org/en/stable/quickstart.html#query-string-parameters) for details.\n\n### Headers\n\nYou can enter request headers as a PSR-7 request object.\n\n\u003e **Note:** You don't need to include the `Content-Type` and `Content-Length` headers. The authentication layer adds these values.\n\n```php\n\u003c?php\nrequire \"vendor/autoload.php\";\n\n$client = \\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile('default');\n\n$headers = [\n  'Accept' =\u003e 'application/json'\n];\n\n$response = $client-\u003eget('/identity-management/v3/user-profile', $headers);\n\necho $response-\u003egetBody();\n```\n\nSee the [Guzzle documentation](https://docs.guzzlephp.org/en/stable/request-options.html#headers) for details on defining headers as a `headers` request option.\n\n### Body data\n\nUse the [Guzzle syntax](https://docs.guzzlephp.org/en/stable/request-options.html#json) to pass simple JSON data as a `json` option in the request.\n\n```php\n\u003c?php\nrequire \"vendor/autoload.php\";\n\n$client = \\Akamai\\Open\\EdgeGrid\\Client::createFromEdgeRcFile('default');\n\n$headers = [\n    'Content-Type' =\u003e 'application/json',\n    'Accept' =\u003e 'application/json'\n  ];\n\n$body = [\n  'json' =\u003e [\n    'contractType' =\u003e 'Billing',\n    'country' =\u003e 'USA',\n    'firstName' =\u003e 'John',\n    'lastName' =\u003e 'Smith',\n    'phone' =\u003e '3456788765',\n    'preferredLanguage' =\u003e 'English',\n    'sessionTimeOut' =\u003e '30',\n    'timeZone' =\u003e 'GMT'\n  ]\n];\n\n$response = $client-\u003eput('/identity-management/v3/user-profile/basic-info', $body, $headers);\n\necho $response-\u003egetBody();\n```\n\n## Command line interface\n\nThis library provides a command line interface (CLI) with a limited set of capabilities that mimic [httpie](http://httpie.org).\n\n### Install\n\nInstall the CLI with a composer `vendor/bin/http` or execute the PHAR file.\n\n```sh\n# Composer installed\n$ ./vendor/bin/http --help\n\n# For Windows\n\u003e php ./vendor/bin/http --help\n\n# PHAR download\nphp akamai-open-edgegrid-client.phar --help\n```\n\n### Arguments\n\nYou can set authentication and specify an HTTP method (case insensitive), its headers, and any JSON body fields.\n\n\u003e **Note:** Our CLI shows all HTTP and body data. JSON is formatted.\n\n|Argument|Description|\n|---|---|\n|`--auth-type={edgegrid,basic,digest}`|Set the authentication type. The default is `none`.|\n|`--auth user:` or `--a user:`|Set the `.edgerc` section to use. Unlike `httpie-edgegrid`, the colon (`:`) is optional.|\n|`Header-Name:value`|Headers and values are colon (`:`) separated.|\n|`jsonKey=value`|Sends `{\"jsonKey\": \"value\"}` in the `POST` or `PUT` body. This will also automatically set the `Content-Type` and `Accept` headers to `application/json`.|\n|`jsonKey:=[1,2,3]`|Allows you to specify raw JSON data, sending `{\"jsonKey\": [1, 2, 3]}` in the body.|\n\n### Limitations\n\n* You can't send `multipart/mime` (file upload) data.\n* Client certs aren't supported.\n* Server certs can't be verified.\n* Output can't be customized.\n* Responses aren't syntax highlighted.\n\n## Guzzle middleware\n\nThis package provides three different middleware handlers you can add transparently when using the `Client`, to a standard `\\GuzzleHttp\\Client` or as a handler.\n\n* The `\\Akamai\\Open\\EdgeGrid\\Handler\\Authentication` for transparent API request signing.\n* The `\\Akamai\\Open\\EdgeGrid\\Handler\\Verbose` for output (or log) responses.\n* The `\\Akamai\\Open\\EdgeGrid\\Handler\\Debug` for output (or log) errors.\n\n### Transparent use\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eHandler\u003c/th\u003e\n            \u003cth\u003eCall\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003eAuthentication\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003e\u003ccode\u003eClient-\u003esetAuthentication()\u003c/code\u003e or pass in an instance of \u003ccode\u003e\\Akamai\\EdgeGrid\\Authentication\u003c/code\u003e to \u003ccode\u003eClient-\u003e__construct()\u003c/code\u003e.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003eVerbose\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003e\u003ccode\u003eClient-\u003esetInstanceVerbose()\u003c/code\u003e or \u003ccode\u003eClient::setVerbose()\u003c/code\u003e passing in on of \u003ccode\u003etrue|resource|[resource output, resource error]\u003c/code\u003e. The default is \u003ccode\u003e[STDOUT, STDERR]\u003c/code\u003e.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003eDebug\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003e\u003ccode\u003eClient-\u003esetInstanceDebug()\u003c/code\u003e, \u003ccode\u003eClient::setDebug()\u003c/code\u003e, or set the \u003ccode\u003edebug\u003c/code\u003e config option with \u003ccode\u003etrue|resource\u003c/code\u003e. The default is \u003ccode\u003eSTDERR\u003c/code\u003e.\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Middleware\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eHandler\u003c/th\u003e\n            \u003cth\u003eExample\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eAuthentication\u003c/td\u003e\n            \u003ctd\u003e\n\u003cpre lang=\"php\"\u003e\n    // Create the Authentication Handler\n    $auth = \\Akamai\\Open\\EdgeGrid\\Handler\\Authentication::createFromEdgeRcFile();\n    // Or hard code your credentials\n    $auth = new \\Akamai\\Open\\EdgeGrid\\Handler\\Authentication;\n    $auth-\u003esetAuth($client_token, $client_secret, $access_token);\n    // Create the handler stack\n    $handlerStack = \\GuzzleHttp\\HandlerStack::create();\n    // Add the Auth handler to the stack\n    $handlerStack-\u003epush($auth);\n    // Add the handler to a regular \\GuzzleHttp\\Client\n    $guzzle = new \\GuzzleHttp\\Client([\n    \"handler\" =\u003e $handlerStack\n    ]);\n\u003c/pre\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eVerbose\u003c/td\u003e\n            \u003ctd\u003e\n\u003cpre lang=\"php\"\u003e\n    // Create the handler stack\n    $handlerStack = HandlerStack::create();\n    // Add the Auth handler to the stack\n    $handlerStack-\u003epush(new \\Akamai\\Open\\EdgeGrid\\Handler\\Verbose());\n    // Add the handler to a regular \\GuzzleHttp\\Client\n    $guzzle = new \\GuzzleHttp\\Client([\n        \"handler\" =\u003e $handlerStack\n    ]);\n\u003c/pre\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eDebug\u003c/td\u003e\n            \u003ctd\u003e\n\u003cpre lang=\"php\"\u003e\n    // Create the handler stack\n    $handlerStack = HandlerStack::create();\n    // Add the Auth handler to the stack\n    $handlerStack-\u003epush(new \\Akamai\\Open\\EdgeGrid\\Handler\\Debug());\n    // Add the handler to a regular \\GuzzleHttp\\Client\n    $guzzle = new \\GuzzleHttp\\Client([\n        \"handler\" =\u003e $handlerStack\n    ]);\n\u003c/pre\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## License\n\nCopyright © 2025 Akamai Technologies, Inc. All rights reserved\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use these files except in compliance with the License.\nYou may obtain a copy of the License at \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e.\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamai%2Fakamaiopen-edgegrid-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakamai%2Fakamaiopen-edgegrid-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamai%2Fakamaiopen-edgegrid-php-client/lists"}