Skip to content

nafresne/guzzle-ovh-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Guzzle OVH Plugin

PHP version Build Status Scrutinizer Code Quality Code Coverage

Guzzle 4 Plugin to use OVH API

More informations on OVH API: https://api.ovh.com/

##Installation

###Install via composer

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add the plugin as a dependency
php composer.phar require nafresne/guzzle-ovh-plugin:dev-master

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

##Basic usage

require 'vendor/autoload.php';

use Nafresne\GuzzleHttp\OvhClient;
use Nafresne\GuzzleHttp\Subscriber\OvhSubscriber;

//Configuration
$config = array(
    'application_key'    => 'ApplicationKey',
    'application_secret' => 'ApplicationSecret',
    'consumer_key'       => 'ConsumerKey'
);

// Create a Guzzle client
$client new OvhClient(['base_url' => 'https://eu.api.ovh.com/1.0/, 'time_url' => 'auth/time');
// and add it the plugin
$client->getEmitter()->attach(new OvhSubscriber($config));

// Now the plugin will add the correct OVH headers to your guzzle request
$response = $client->get('/data')->send();

##Symfony 2 usage

parameters:
    ovh.baseurl: "https://eu.api.ovh.com/1.0/"
    ovh.timeurl: "auth/time"
    ovh.config:
        application_key: ApplicationKey
        application_secret: ApplicationSecret
        consumer_key: ConsumerKey

services:
    guzzle.ovh.client:
        class: Nafresne\GuzzleHttp\OvhClient
        arguments:
            - { base_url: %ovh.baseurl%, time_url: %ovh.timeurl%, emitter: @guzzle.ovh.emitter }

    guzzle.ovh.emitter:
        class: GuzzleHttp\Event\Emitter
        calls:
            - [attach, [@guzzle.ovh.subscriber]]

    guzzle.ovh.subscriber:
        class: Nafresne\GuzzleHttp\Subscriber\OvhSubscriber
        arguments: [%ovh.config%]
$client = $this->container->get('guzzle.ovh.client');
$response = $client->get('hosting/web');
$body = $response->getBody();

##Tests

composer install && vendor/bin/phpunit

##License

This plugin is licensed under the MIT License

About

OVH Guzzle Plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages