navraj-sharma / sparrowsms
Sparrow SMS notification channel for Laravel
Requires
- php: >=7.3
- guzzlehttp/guzzle: *
- illuminate/notifications: *
- illuminate/support: *
- laravel/framework: ^8.40
- laravel/tinker: ^2.5
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2025-04-29 01:12:22 UTC
README
This package makes it easy to send notifications using SparrowSMS with Laravel 5.5+, 6.0 and 7.0
Contents
Installation
You can install this package via composer:
composer require navraj-sharma/sparrowsms
Setting up the SparrowSMS service
Add your SparrowSMS configurations to your config/sparrowsms.php:
// config/sparrowsms.php ... return [ 'token' => env('SPARROWSMS_TOKEN'), 'from' => env('SPARROWSMS_FROM'), 'api_endpoint' => env('SPARROWSMS_API_ENDPOINT', 'http://api.sparrowsms.com/v2/'), 'sandbox' => env('SPARROWSMS_SANDBOX', false), 'methods' => [ 'send' => 'sms/', 'credit' => 'credit/' ], 'debug' => env('APP_DEBUG', false), ] ...
Usage
You can use the channel in your via() method inside the notification:
use Illuminate\Notifications\Notification; use NavrajSharma\SparrowSMS\SparrowSMSMessage; class SendSMS extends Notification { public function via($notifiable) { return ["sparrowsms"]; } public function toSparrowSMS($notifiable) { return (new SparrowSMSMessage("SMS Sent Via SparrowSMS Service")); } }
In your notifiable model, make sure to include a routeNotificationForSparrowSMS() method, which returns a phone number or an array of phone numbers.
public function routeNotificationForSparrowSMS() { return $this->mobile; }
On-Demand Notifications
Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the Notification::route method, you may specify ad-hoc notification routing information before sending the notification:
Notification::route('sparrowsms', '9801110000') ->notify(new SendSMS());
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email info@navraj.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.