mmockelyn / laravel-ovh-sms
OVH SMS API integration for Laravel 7+.
Requires
- php: ^7.4|^8.0
- illuminate/notifications: ^7.0|^8.0|^9.0
- illuminate/support: ^8.0|^9.0
- ovh/ovh: ^v3.0.0
This package is not auto-updated.
Last update: 2025-02-07 19:20:06 UTC
README
This is an unofficial OVH SMS integration of the ovh/php-ovh library for Laravel 7+.
- Original PHP OVH library
- Based on Nexmo notification channel
Summary
Installation
Currently, this package isn't packaged with packagist (https://packagist.org/). You must add a private repository to your composer.json file in order to use this package. You can add private repository in your composer.json file by adding this section :
{ "repositories": [ { "name": "orykami/laravel-ovh-sms", "type": "git", "url": "https://github.com/orykami/laravel-ovh-sms" } ] }
Require this package with composer:
composer require orykami/laravel-ovh-sms
After updating composer, add the ServiceProvider to the providers array in config/app.php:
Illuminate\Notifications\OvhSmsChannelServiceProvider::class,
Configuration
This package require some configuration in config/services.php
return [ // Add configuration to third party services 'ovh' => [ 'app_key' => env('OVH_APP_KEY', 'YOUR_APP_KEY_HERE'), 'app_secret' => env('OVH_APP_SECRET', 'YOUR_APP_SECRET_HERE'), 'endpoint' => env('OVH_ENDPOINT', 'OVH_ENDPOINT_HERE'), 'consumer_key' => env('OVH_CONSUMER_KEY', 'YOUR_CONSUMER_KEY_HERE'), 'sms_account' => env('OVH_SMS_ACCOUNT', 'sms-xxxxxxx-x'), 'sms_default_sender' => env('OVH_SMS_DEFAULT_SENDER', 'SENDER_NAME')), 'sms_sandbox_mode' => env('OVH_SMS_SANDBOX_MODE', false)), ], ];
Using with Laravel Notifications
This package can be used as a driver for Laravel Notifications (Laravel >= 7.X).
Example notification
Here's a simple notification example.
namespace App\Notifications; use Illuminate\Notifications\Channels\OvhSmsChannel; use Illuminate\Notifications\Messages\OvhSmsMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { /** * Notification via OvhSmsChannel. */ public function via($notifiable) { return [OvhSmsChannel::class]; } /** * Your notification must implements "toOvh()" */ public function toOvh($notifiable) { return (new OvhSmsMessage('A new invoice was paid! Amount: $9.00')); } }
Also, your Notifiable model must implements routeNotificationForOvhSms().
namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Returns the user's phone number. */ public function routeNotificationForOvhSms() { return $this->phone; // Ex: +33611223344 } }
You're all set to use the new Laravel Notifications system ! :-) Be aware that Channel method send will return OVH credits consumed (if needed for quotas/metrics).
Licence
MIT