envoisms / laravel-otp
Laravel Notification Channel & OTP Package for EnvoiSMS.ma
Package info
pkg:composer/envoisms/laravel-otp
v1.0.0
2026-07-23 15:22 UTC
Requires
- php: >=8.0
- envoisms/envoisms-php: ^1.0
- illuminate/notifications: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Official Laravel Notification Channel & OTP Package for EnvoiSMS.ma — Passerelle SMS & WhatsApp Business and API SMS Maroc.
For full API documentation, visit the Passerelle SMS & WhatsApp Business. For pricing plans and credit packs, visit API SMS Maroc.
Installation
Install via Composer:
composer require envoisms/laravel-otp
Configuration
Add your API credentials to .env:
ENVOISMS_API_KEY=your_api_key_here ENVOISMS_FROM=MonBusiness
Optionally publish or add to config/services.php:
'envoisms' => [ 'api_key' => env('ENVOISMS_API_KEY'), 'from' => env('ENVOISMS_FROM', 'EnvoiSMS'), ],
Usage in Laravel Notifications
Create a notification class:
namespace App\Notifications; use EnvoiSMS\Laravel\EnvoiSMSChannel; use EnvoiSMS\Laravel\Messages\EnvoiSMSMessage; use Illuminate\Notifications\Notification; class SendOtpNotification extends Notification { public function via($notifiable): array { return [EnvoiSMSChannel::class]; } public function toEnvoiSMS($notifiable): EnvoiSMSMessage { return (new EnvoiSMSMessage()) ->asOtp(brand: 'MonApp', codeLength: 6, expiry: 600); } }
Send the notification to any model with a phone or routeNotificationForEnvoiSMS() method:
$user->notify(new SendOtpNotification());
Using the Facade Directly
use EnvoiSMS\Laravel\Facades\EnvoiSMS; // Send OTP $response = EnvoiSMS::sendOtp([ 'to' => '+212600000000', 'brand' => 'MonApp', ]); // Check OTP Code $result = EnvoiSMS::checkOtp( sessionId: $response['session_id'], code: '123456' ); if ($result['verified']) { // Code valid }
Documentation & Tarifs
- Guides et référence API : Passerelle SMS & WhatsApp Business
- Tarifs et packs SMS Maroc : API SMS Maroc
License
MIT