- shoutout
- dialog
- mobitel (coming soon)
You can install the package via composer:
composer require isurindu/laravel-sms
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php
file:
'providers' => [
// ...
Isurindu\LaravelSms\LaravelSmsServiceProvider::class,
];
You can publish config
php artisan vendor:publish --provider="Isurindu\LaravelSms\LaravelSmsServiceProvider::class"
configaration in config/sms.php
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'),
],
];
<?php
use Isurindu\LaravelSms\Facades\Sms;
Sms::to('94702125238')
->send('hello world');
Sms::provider('mobitel')
->to('94702125238')
->send('hello world');
if provider is mobitel class name must be located at Gateways\MobitelGateway
<?php
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');
}
}