envoisms/laravel-otp

Laravel Notification Channel & OTP Package for EnvoiSMS.ma

Maintainers

Package info

github.com/FraudShield1/laravel-otp

Homepage

pkg:composer/envoisms/laravel-otp

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-07-23 15:22 UTC

This package is auto-updated.

Last update: 2026-07-23 16:20:57 UTC


README

Official Laravel Notification Channel & OTP Package for EnvoiSMS.ma — Morocco's SMS, WhatsApp & Verification API platform.

For full API documentation, visit EnvoiSMS Documentation.

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

Full platform documentation is available at https://envoisms.ma/fr/docs.

License

MIT