2017 © Pedro Peláez
 

symfony-bundle ovh-bundle

OVH SDK integration

image

tilleuls/ovh-bundle

OVH SDK integration

  • Tuesday, July 17, 2018
  • by dunglas
  • Repository
  • 15 Watchers
  • 25 Stars
  • 31,208 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 2 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

CoopTilleulsOVHBundle: OVH SDK integration in Symfony

This bundle integrates OVH's offical PHP SDK in the Symfony framework., (*1)

Build Status SensioLabsInsight Coverage Status, (*2)

Installation

Use Composer to install the bundle:, (*3)

composer require tilleuls/ovh-bundle, (*4)

Then, update your app/config/AppKernel.php file:, (*5)

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new CoopTilleuls\OvhBundle\CoopTilleulsOvhBundle(),
            // ...
        );

        return $bundles;
    }

Configure the bundle in app/config/config.yml:, (*6)

coop_tilleuls_ovh:
    endpoint_name:      "%ovh_endpoint_name%"
    application_key:    "%ovh_application_key%"
    application_secret: "%ovh_application_secret%"
    consumer_key:       "%ovh_consumer_key%"

Finally, update your app/config/parameters.yml file to store your OVH API credentials:, (*7)

parameters:
    # ...
    ovh_endpoint_name:      "ovh-eu"
    ovh_application_key:    "MyOvhApplicationKey"
    ovh_application_secret: "MyOvhApplicationSecret"
    ovh_consumer_key:       "MyOvhConsumerKey"

Usage

The bundle automatically registers a ovh service in the Dependency Injection Container. That service is an instance of \Ovh\Api., (*8)

Example usage in a controller:, (*9)

// ...

    public function smsAction(\Ovh\Api $ovhApi)
    {
        // Send a SMS
        $ovhApi
            ->post(
                sprintf('/sms/%s/users/%s/jobs', 'my-service-name', 'my-login'),
                [
                    'message' => 'Si tu veux me parler, envoie-moi un... fax !',
                    'receivers' => ['+33612345678'],
                    'sender' => 'my-login',
                ]
            )
        ;

        // ...
    }

// ...
}

Credits

Created by Kévin Dunglas for Les-Tilleuls.coop., (*10)

The Versions