{"id":18446429,"url":"https://github.com/ovh/php-ovh","last_synced_at":"2025-05-14T11:09:52.581Z","repository":{"id":21521100,"uuid":"24840263","full_name":"ovh/php-ovh","owner":"ovh","description":"Lightweight PHP wrapper for OVH APIs. That's the easiest way to use OVH.com APIs in your PHP applications.","archived":false,"fork":false,"pushed_at":"2025-02-17T11:11:59.000Z","size":255,"stargazers_count":294,"open_issues_count":15,"forks_count":109,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-03-31T15:06:55.380Z","etag":null,"topics":["api-wrapper"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ovh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-06T09:31:40.000Z","updated_at":"2025-03-04T22:05:40.000Z","dependencies_parsed_at":"2023-10-13T17:14:09.499Z","dependency_job_id":"66fbeb61-89f1-4a14-98c2-97e45330da4c","html_url":"https://github.com/ovh/php-ovh","commit_stats":{"total_commits":74,"total_committers":24,"mean_commits":"3.0833333333333335","dds":0.8513513513513513,"last_synced_commit":"9a29f720d03f0a8cae642ba5c97f51d100144c57"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fphp-ovh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fphp-ovh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fphp-ovh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fphp-ovh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ovh","download_url":"https://codeload.github.com/ovh/php-ovh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247688317,"owners_count":20979635,"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":["api-wrapper"],"created_at":"2024-11-06T07:09:17.996Z","updated_at":"2025-04-11T04:19:02.719Z","avatar_url":"https://github.com/ovh.png","language":"PHP","readme":"# OVHcloud APIs lightweight PHP wrapper\n\n[![PHP Wrapper for OVHcloud APIs](https://github.com/ovh/php-ovh/blob/master/img/logo.png)](https://packagist.org/packages/ovh/ovh)\n\n[![Source Code](https://img.shields.io/badge/source-ovh/php--ovh-blue.svg?style=flat-square)](https://github.com/ovh/php-ovh)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/ovh/php-ovh/ci.yaml?label=CI\u0026logo=github\u0026style=flat-square)](https://github.com/ovh/php-ovh/actions?query=workflow%3ACI)\n[![Codecov Code Coverage](https://img.shields.io/codecov/c/gh/ovh/php-ovh?label=codecov\u0026logo=codecov\u0026style=flat-square)](https://codecov.io/gh/ovh/php-ovh)\n[![Total Downloads](https://img.shields.io/packagist/dt/ovh/ovh.svg?style=flat-square)](https://packagist.org/packages/ovh/ovh)\n\nThis PHP package is a lightweight wrapper for OVHcloud APIs.\n\nThe easiest way to use OVHcloud APIs in your PHP applications.\n\nCompatible with PHP 7.4, 8.0, 8.1, 8.2.\n\n## Installation\n\nInstall this wrapper and integrate it inside your PHP application with [Composer](https://getcomposer.org):\n\n    composer require ovh/ovh\n\n## Basic usage\n\n```php\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\nuse \\Ovh\\Api;\n\n// Api credentials can be retrieved from the urls specified in the \"Supported endpoints\" section below.\n$ovh = new Api($applicationKey,\n                $applicationSecret,\n                $endpoint,\n                $consumerKey);\necho 'Welcome '.$ovh-\u003eget('/me')['firstname'];\n```\n\n## Advanced usage\n\n### Handle exceptions\n\nUnder the hood, `php-ovh` uses [Guzzle](http://docs.guzzlephp.org/en/latest/quickstart.html) by default to issue API requests.\n\nIf everything goes well, it will return the response directly as shown in the examples above.\n\nIf there is an error like a missing endpoint or object (404), an authentication or authorization error (401 or 403) or a parameter error, the Guzzle will raise a ``GuzzleHttp\\Exception\\ClientException`` exception. For server-side errors (5xx), it will raise a ``GuzzleHttp\\Exception\\ServerException`` exception.\n\nYou can get the error details with a code like:\n\n```php\ntry {\n    echo \"Welcome \" . $ovh-\u003eget('/me')['firstname'];\n} catch (GuzzleHttp\\Exception\\ClientException $e) {\n    $response = $e-\u003egetResponse();\n    $responseBodyAsString = $response-\u003egetBody()-\u003egetContents();\n    echo $responseBodyAsString;\n}\n```\n\n### Customize HTTP client configuration\n\nYou can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests\n\n```php\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\nuse \\Ovh\\Api;\nuse GuzzleHttp\\Client;\n\n// Instantiate a custom Guzzle HTTP client and tweak it\n$client = new Client();\n$client-\u003esetDefaultOption('timeout', 1);\n$client-\u003esetDefaultOption('headers', ['User-Agent' =\u003e 'api_client']);\n\n// Api credentials can be retrieved from the urls specified in the \"Supported endpoints\" section below.\n// Inject the custom HTTP client as the 5th argument of the constructor\n$ovh = new Api($applicationKey,\n                $applicationSecret,\n                $endpoint,\n                $consumerKey,\n                $client);\n\necho 'Welcome '.$ovh-\u003eget('/me')['firstname'];\n```\n\n### Authorization flow\n\nThis flow will allow you to request consumerKey from an OVHcloud account owner.\nAfter allowing access to his account, he will be redirected to your application.\n\nSee \"OVHcloud API authentication\" section below for more information about the authorization flow.\n\n```php\nuse \\Ovh\\Api;\nsession_start();\n\n// Api credentials can be retrieved from the urls specified in the \"Supported endpoints\" section below.\n$ovh = new Api($applicationKey,\n                $applicationSecret,\n                $endpoint);\n\n// Specify the list of API routes you want to request\n$rights = [\n    [ 'method' =\u003e 'GET',  'path' =\u003e '/me*' ],\n];\n\n// After allowing your application access, the customer will be redirected to this URL.\n$redirectUrl = 'https://your_application_redirect_url'\n\n$credentials = $ovh-\u003erequestCredentials($rights, $redirectUrl);\n\n// Save consumer key and redirect to authentication page\n$_SESSION['consumerKey'] = $credentials['consumerKey'];\nheader('location: '. $credentials['validationUrl']);\n// After successful redirect, the consumerKey in the session will be activated and you will be able to use it to make API requests like in the \"Basic usage\" section above.\n```\n\n### Code sample: Enable network burst on GRA1 dedicated servers\n\nHere is a more complex example of how to use the wrapper to enable network burst on GRA1 dedicated servers.\n\n```php\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\nuse \\Ovh\\Api;\n\n// Api credentials can be retrieved from the urls specified in the \"Supported endpoints\" section below.\n$ovh = new Api($applicationKey,\n                $applicationSecret,\n                $endpoint,\n                $consumerKey);\n\n// Load the list of dedicated servers\n$servers = $ovh-\u003eget('/dedicated/server/');\nforeach ($servers as $server) {\n    // Load the server details\n    $details = $ovh-\u003eget('/dedicated/server/'.$server);\n    // Filter servers only inside GRA1\n    if ($details['datacenter'] == 'gra1') {\n        // Activate burst on server\n        $content = ['status' =\u003e 'active'];\n        $ovh-\u003eput('/dedicated/server/'.$server.'/burst', $content);\n        echo 'Burst enabled on '.$server;\n    }\n}\n```\n\n### More code samples\n\nDo you want to use OVHcloud APIs? Maybe the script you want is already written in the [example part](examples/README.md) of this repository!\n\n## OAuth2 authentification\n\n`php-ovh` supports two forms of authentication:\n\n* OAuth2, using scopped service accounts, and compatible with OVHcloud IAM\n* application key \u0026 application secret \u0026 consumer key (covered in the next chapter)\n\nFor OAuth2, first, you need to generate a pair of valid `client_id` and `client_secret`: you can proceed by\n[following this documentation](https://help.ovhcloud.com/csm/en-manage-service-account?id=kb_article_view\u0026sysparm_article=KB0059343).\n\nOnce you have retrieved your `client_id` and `client_secret`, you can instantiate an API client using:\n\n```php\nuse \\Ovh\\Api;\n\n$ovh = Api::withOauth2($clientId, $clientSecret, $endpoint);\n```\n\nSupported endpoints are only `ovh-eu`, `ovh-ca` and `ovh-us`.\n\n## Custom OVHcloud API authentication\n\nTo use the OVHcloud APIs you need three credentials:\n\n* An application key\n* An application secret\n* A consumer key\n\nThe application key and secret are not granting access to a specific account and are unique to identify your application.\nThe consumer key is used to grant access to a specific OVHcloud account to a specified application.\n\nThey can be created separately if your application is intended to be used by multiple accounts (your app will need to implement an authorization flow).\nIn the authorization flow, the customer will be prompted to allow access to his account to your application, then he will be redirected to your application.\n\nThey can also be created together if your application is intended to use only your own OVHcloud account.\n\n## Supported endpoints\n\n### OVHcloud Europe\n\n* `$endpoint = 'ovh-eu';`\n* Documentation: \u003chttps://eu.api.ovh.com/\u003e\n* Console: \u003chttps://eu.api.ovh.com/console\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://eu.api.ovh.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://eu.api.ovh.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n### OVHcloud US\n\n* `$endpoint = 'ovh-us';`\n* Documentation: \u003chttps://api.us.ovhcloud.com/\u003e\n* Console: \u003chttps://api.us.ovhcloud.com/console\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://api.us.ovhcloud.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://api.us.ovhcloud.com/createToken/\u003e\n\n### OVHcloud North America / Canada\n\n* `$endpoint = 'ovh-ca';`\n* Documentation: \u003chttps://ca.api.ovh.com/\u003e\n* Console: \u003chttps://ca.api.ovh.com/console\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://ca.api.ovh.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://ca.api.ovh.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n### So you Start Europe\n\n* `$endpoint = 'soyoustart-eu';`\n* Documentation: \u003chttps://eu.api.soyoustart.com/\u003e\n* Console: \u003chttps://eu.api.soyoustart.com/console/\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://eu.api.soyoustart.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://eu.api.soyoustart.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n### So you Start North America\n\n* `$endpoint = 'soyoustart-ca';`\n* Documentation: \u003chttps://ca.api.soyoustart.com/\u003e\n* Console: \u003chttps://ca.api.soyoustart.com/console/\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://ca.api.soyoustart.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://ca.api.soyoustart.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n### Kimsufi Europe\n\n* `$endpoint = 'kimsufi-eu';`\n* Documentation: \u003chttps://eu.api.kimsufi.com/\u003e\n* Console: \u003chttps://eu.api.kimsufi.com/console/\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://eu.api.kimsufi.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://eu.api.kimsufi.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n### Kimsufi North America\n\n* `$endpoint = 'kimsufi-ca';`\n* Documentation: \u003chttps://ca.api.kimsufi.com/\u003e\n* Console: \u003chttps://ca.api.kimsufi.com/console/\u003e\n* Create application credentials (generate only application credentials, your app will need to implement an authorization flow): \u003chttps://ca.api.kimsufi.com/createApp/\u003e\n* Create account credentials (all keys at once for your own account only): \u003chttps://ca.api.kimsufi.com/createToken/\u003e\n* Community support: api-subscribe@ml.ovh.net\n\n## Building documentation\n\nDocumentation is based on phpdocumentor and inclued in the project.\nTo generate documentation, it's possible to use directly:\n\n    composer phpdoc\n\nDocumentation is available in docs/ directory.\n\n## Code check / Linting\n\nCode check is based on PHP CodeSniffer and inclued in the project.\nTo check code, it's possible to use directly:\n\n    composer phpcs\n\nCode linting is based on PHP Code Beautifier and Fixer and inclued in the project.\nTo lint code, it's possible to use directly:\n\n    composer phpcbf\n\n## Testing\n\nTests are based on phpunit and inclued in the project.\nTo run functionals tests, you need to provide valid API credentials, that you can provide them via environment:\n\n    APP_KEY=xxx APP_SECRET=xxx CONSUMER=xxx ENDPOINT=xxx composer phpunit\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/ovh/php-ovh/blob/master/CONTRIBUTING.rst) for details.\n\n## Credits\n\n[All Contributors from this repo](https://github.com/ovh/php-ovh/contributors)\n\n## License\n\n (Modified) BSD license. Please see [LICENSE](https://github.com/ovh/php-ovh/blob/master/LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovh%2Fphp-ovh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovh%2Fphp-ovh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovh%2Fphp-ovh/lists"}