tilleuls / ovh-bundle
OVH SDK integration
Installs: 121 592
Dependents: 0
Suggesters: 0
Security: 0
Stars: 29
Watchers: 27
Forks: 6
Open Issues: 3
Type:symfony-bundle
Requires
- php: >=7.2
- ovh/ovh: ^2.0
- symfony/config: ~4.0|~5.0
- symfony/dependency-injection: ~4.0|~5.0
- symfony/http-kernel: ~4.0|~5.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-11 19:26:07 UTC
README
This bundle integrates OVH's offical PHP SDK in the Symfony framework.
Installation
Use Composer to install the bundle:
composer require tilleuls/ovh-bundle
Then, update your app/config/AppKernel.php
file:
public function registerBundles() { $bundles = array( // ... new CoopTilleuls\OvhBundle\CoopTilleulsOvhBundle(), // ... ); return $bundles; }
Configure the bundle in app/config/config.yml
:
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:
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
.
Example usage in a controller:
// ... 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.