This guide specifically targets developers comming from the legacy wrappers previously distributed on https://api.ovh.com/g934.first_step_with_api. It highligts the main evolutions between these 2 major version as well as some tips to help with the migration. If you have any further questions, feel free to drop a mail on [email protected] ([email protected] to subscribe).
Legacy wrappers were distributed as zip files for direct integration into final projects. This new version is fully integrated with Composer standard distribution channels.
Recommended way to add php-ovh
to a project: add ovh
to a
composer.json
file at the root of the project.
# file: composer.json "require": { "ovh/ovh": "dev-master" }
To refresh the dependencies, just run:
composer install
The new PHP wrapper use composer to manage project dependencies. If you want to use the client class, usage of namespace is more confortable with PSR-4 autoloading system. You can find more informations about autoloading
require('OvhApi/OvhApi.php');
use \Ovh\Api;
$client = OvhApi(OVH_API_EU, 'app key', 'app secret', 'consumer key');
$client = Client('app key', 'app secret', 'ovh-eu', 'consumer key');
Similarly, OVH_API_CA
has been replaced by 'ovh-ca'
.
# API helpers
$content = (object) array("param_1" => "value_1", "param_2" => "value_2");
$data = $client->get('/my/method?filter_1=value_1&filter_2=value_2');
$data = $client->post('/my/method', $content);
$data = $client->put('/my/method', $content);
$data = $client->delete('/my/method');
# API helpers
$content = (object) array("param_1" => "value_1", "param_2" => "value_2");
$data = $client->get('/my/method?filter_1=value_1&filter_2=value_2');
$data = $client->post('/my/method', $content);
$data = $client->put('/my/method', $content);
$data = $client->delete('/my/method');