Laravel Package that's allows you to send SMS and SMS notifications via SmsMisr from your Laravel application.
- PHP >= 8
- Laravel 8+
- account in Sms Misr (username and password)
- Installation via composer :
composer require ghanem/laravel-smsmisr
If you're using Laravel 5.5 or above, the package will automatically register the Smsmisr
provider and facade.
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
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");
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
);
}
}
Ghanem\LaravelSmsmisr\SmsmisrMessage
(new SmsmisrMessage(string $message, string $to))
->to(string $to)
->from(string $from)
->unicode(bool $unicode = true)
MIT