PHP code example of isurindu / laravel-sms

1. Go to this page and download the library: Download isurindu/laravel-sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

isurindu / laravel-sms example snippets


'providers' => [
    // ...
    Isurindu\LaravelSms\LaravelSmsServiceProvider::class,
];

return [
    'default_sms_provider'=>env('SMS_PROVIDER', 'dialog'),//dialog,shoutout,log
    'fallback_sms_provider'=>env('SMS_PROVIDER_FALLBACK', ''), //alternative sms provider for an emergency

    'shoutout'=>[
        'api_key'=>env('SHOUTOUT_API_KEY', 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX'),
        'from'=>env('SHOUTOUT_FROM_NUMBER', 'YOUR_NUMBER_MASK_HERE'),
    ],
    'dialog'=>[
        'username'=>env('DIALOG_USERNAME', ''),
        'password'=>env('DIALOG_PASSWORD', ''),
        'from'=>env('DIALOG_FROM_NUMBER', 'YOUR_NUMBER_MASK_HERE'),
    ],
];



use Isurindu\LaravelSms\Facades\Sms;

Sms::to('94702125238')
    ->send('hello world');

Sms::provider('mobitel')
    ->to('94702125238')
    ->send('hello world');


namespace Isurindu\LaravelSms\Gateways;

use Isurindu\LaravelSms\Interfaces\SmsInterface;
use Isurindu\LaravelSms\Exceptions\LaravelSmsGatewayException;

class MobitelGateway implements SmsInterface
{
    public function sendSms($to, $msg, $from)
    {
        //send sms logic here
        //if something went wrong  throw new LaravelSmsGatewayException('something went wrong');

    }
}
bash
php artisan vendor:publish --provider="Isurindu\LaravelSms\LaravelSmsServiceProvider::class"