Git Product home page Git Product logo

laravel-ovh-sms's Introduction

Laravel OVH SMS

This is an unofficial OVH SMS integration of the ovh/php-ovh library for Laravel 7+.

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 "toOvhSms()"
     */
    public function toOvhSms($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

laravel-ovh-sms's People

Contributors

helitik avatar jerrybels avatar orykami avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-ovh-sms's Issues

InvalidArgumentException

Hi,
I try to install you package on a laravel 8 application, but receive this error ๐Ÿ‘
[InvalidArgumentException]

  Could not find a matching version of package orykami/laravel-ovh-sms. Check the package spelling, your version constraint and that the package is available in a stability which matches your mi  
  nimum-stability (dev).   

Do you have any idea of what append?

Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.