ghanem / laravel-smsmisr
Send SMS and SMS Notification via sms misr for Laravel
Installs: 2 716
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 2
Forks: 7
Open Issues: 2
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: >=5.3
- symfony/psr-http-message-bridge: ^2.0
README
Laravel Package that's allows you to send SMS and SMS notifications via SmsMisr from your Laravel application.
Summary
Requirements
- PHP >= 8
- Laravel 8+
- account in Sms Misr (username and password)
Installation
- Installation via composer :
composer require ghanem/laravel-smsmisr
Laravel 5.5+
If you're using Laravel 5.5 or above, the package will automatically register the Smsmisr
provider and facade.
Laravel 5.4 and below
Add Ghanem\LaravelSmsmisr\SmsmisrServiceProvider
to the providers
array in your config/app.php
:
'providers' => [ // Other service providers... Ghanem\LaravelSmsmisr\SmsmisrServiceProvider::class, ],
Or add an alias in your config/app.php
:
'aliases' => [ ... 'Smsmisr' => Ghanem\LaravelSmsmisr\Smsmisr::class, ],
- Publish the config & views by running smsmisr :
php artisan vendor:publish --provider="Ghanem\LaravelSmsmisr\SmsmisrServiceProvider"
- Then update
config/smsmisr.php
with your credentials. Alternatively, you can update your.env
file with the following:
SMSMISR_USERNAME=my_username SMSMISR_PASSWORD=my_password SMSMISR_SENDER=my_sender
Usage
If you want to use the facade interface, you can use
the facade class when needed:
use use Ghanem\LaravelSmsmisr\Facades\Smsmisr; ... public function myMethod() { Smsmisr::send("hello world", "201010101010"); }
if you need use golbal:
// Global app('smsmisr')->send("hello world", "201010101010");
Notifications
You can use the channel in your via() method inside the notification:
namespace App\Notifications; use Ghanem\LaravelSmsmisr\SmsmisrChannel; use Ghanem\LaravelSmsmisr\SmsmisrMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [SmsmisrChannel::class]; } public function toSmsmisr($notifiable) { return new SmsmisrMessage( 'Your message here', $notifiable->phone ); } }
API
Ghanem\LaravelSmsmisr\SmsmisrMessage
(new SmsmisrMessage(string $message, string $to))
->to(string $to)
->from(string $from)
->unicode(bool $unicode = true)
Licence
MIT