ghanem/laravel-smsmisr

Send SMS and SMS Notification via sms misr for Laravel

v3.0.1 2022-03-04 23:35 UTC

This package is auto-updated.

Last update: 2024-10-27 21:29:42 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

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

Sponsor

💚️ Become a Sponsor