2017 © Pedro Peláez
 

library guzzle-ovh-plugin

Guzzle plugin to manage OVH authentication

image

nafresne/guzzle-ovh-plugin

Guzzle plugin to manage OVH authentication

  • Thursday, November 6, 2014
  • by nafresne
  • Repository
  • 1 Watchers
  • 1 Stars
  • 343 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Guzzle OVH Plugin

PHP version Build Status Scrutinizer Code Quality Code Coverage, (*1)

Guzzle 4 Plugin to use OVH API, (*2)

More informations on OVH API: https://api.ovh.com/, (*3)

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:, (*4)

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, (*5)

The Versions

06/11 2014

dev-master

9999999-dev https://github.com/nafresne/guzzle-ovh-plugin

Guzzle plugin to manage OVH authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

plugin api authentication rest guzzle ovh