PHPackages                             mr-rijal/laravel-sms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mr-rijal/laravel-sms

ActiveLibrary[API Development](/categories/api)

mr-rijal/laravel-sms
====================

Unified, extensible SMS gateway for Laravel

1.0.1(1mo ago)328↓50%5[1 issues](https://github.com/mr-rijal/laravel-sms/issues)MITPHPPHP ^8.2CI passing

Since Jan 8Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/mr-rijal/laravel-sms)[ Packagist](https://packagist.org/packages/mr-rijal/laravel-sms)[ RSS](/packages/mr-rijal-laravel-sms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (14)Versions (9)Used By (0)

Laravel SMS
===========

[](#laravel-sms)

[![Workflow](https://camo.githubusercontent.com/6fbb9762d843ea1e4ebe366f92648c75e2a08c51f7ffa8db571e6f62e58a0397/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d722d72696a616c2f6c61726176656c2d736d732f2e676974687562253246776f726b666c6f777325324663692e796d6c)](https://github.com/mr-rijal/laravel-sms/actions)[![Latest Version](https://camo.githubusercontent.com/0fb10b4430258187483f00c1049c1f815adc516907ac6c26a0354e6ea2fa7207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d722d72696a616c2f6c61726176656c2d736d732e737667)](https://packagist.org/packages/mr-rijal/laravel-sms)[![PHP](https://camo.githubusercontent.com/4a3501997c3b637d1379d42bd6a5548e93415fe0a04078ee66f76594a5cb346e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242343f7374796c653d666c6174266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/4a3501997c3b637d1379d42bd6a5548e93415fe0a04078ee66f76594a5cb346e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242343f7374796c653d666c6174266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Latest Stable Version](https://camo.githubusercontent.com/415e6c6b6cf466c4115d422f646d05441a2cc106e941e03ca0df78d9fdc80567/68747470733a2f2f706f7365722e707567782e6f72672f6d722d72696a616c2f6c61726176656c2d736d732f76)](https://packagist.org/packages/mr-rijal/laravel-sms)[![License](https://camo.githubusercontent.com/104b18bc35cd78134a933a9bb665eac1437643dcb2b1004cfd01580b5757ee78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d722d72696a616c2f6c61726176656c2d736d73)](LICENSE)[![Downloads](https://camo.githubusercontent.com/6c07de47e3ccf55475d37d79f3eb7c2a593fcc514634f09d479f802a982d45f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d722d72696a616c2f6c61726176656c2d736d732e737667)](https://packagist.org/packages/mr-rijal/laravel-sms)[![Star](https://camo.githubusercontent.com/59448f7ef9ca2240ab65c78224cf0463ca2ede87ef50a287bcc35786b6997473/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6d722d72696a616c2f6c61726176656c2d736d73)](https://github.com/mr-rijal/laravel-sms)

A unified, extensible SMS gateway for Laravel. Send SMS via Twilio, Vonage, MSG91, Sparrow, AWS SNS, WhatsApp, or your own driver—with one simple API.

Features
--------

[](#features)

- **Multiple drivers** — Twilio, Vonage (Nexmo), MSG91, Sparrow SMS, AWS SNS, WhatsApp Business API
- **Laravel Notifications** — Use the `sms` channel and `SmsNotification` out of the box
- **Queue &amp; schedule** — `sendLater()` and `sendLaterAt()` for queued and scheduled messages
- **Templates** — Template IDs and variables for providers that support them (e.g. MSG91, WhatsApp)
- **Events** — `SmsSending` and `SmsSent` for logging, auditing, or blocking
- **Macros** — Extend the facade with custom methods (e.g. `sendOtp()`)
- **Random driver** — Load balancing across multiple providers via `random_drivers`
- **Fake driver** — Test without hitting real APIs
- **Custom drivers** — Implement `SmsProvider` and register your own gateway

Requirements
------------

[](#requirements)

- PHP 8.2 or higher on Laravel 11–12; Laravel 13 requires PHP 8.3 or higher (upstream constraint)
- Laravel 11.x and above
- Guzzle HTTP (required by drivers that call APIs)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require mr-rijal/laravel-sms
```

Publish the config file:

```
php artisan vendor:publish --tag=sms-config
```

This creates `config/sms.php`. Set your default driver and provider credentials in `.env`:

```
SMS_PROVIDER=twilio

# Example: Twilio
TWILIO_SID=
TWILIO_TOKEN=
TWILIO_FROM=
```

Configuration
-------------

[](#configuration)

The published config defines the default driver, queue behaviour, and credentials per provider. Main options:

KeyDescription`default`Default driver name (e.g. `twilio`, `fake`)`queue`When `true`, `send()` queues instead of sending now`drivers`Map of driver names to driver classes`providers`Credentials per driver (keys, tokens, etc.)`random_drivers`Drivers used when provider is `random`Example `config/sms.php` layout:

```
return [
    'default' => env('SMS_PROVIDER', 'fake'),
    'queue'   => env('SMS_QUEUE', false),

    'drivers' => [
        'twilio'  => \MrRijal\LaravelSms\Drivers\TwilioDriver::class,
        'sparrow' => \MrRijal\LaravelSms\Drivers\SparrowDriver::class,
        'msg91'   => \MrRijal\LaravelSms\Drivers\Msg91Driver::class,
        'vonage'  => \MrRijal\LaravelSms\Drivers\VonageDriver::class,
        'aws_sns' => \MrRijal\LaravelSms\Drivers\AwsSnsDriver::class,
        'fake'    => \MrRijal\LaravelSms\Drivers\FakeDriver::class,
    ],

    'providers' => [
        'twilio'  => [
            'sid'   => env('TWILIO_SID'),
            'token' => env('TWILIO_TOKEN'),
            'from'  => env('TWILIO_FROM'),
        ],
        // … other providers
    ],

    'random_drivers' => ['twilio', 'msg91'],
];
```

Usage
-----

[](#usage)

### Sending a message

[](#sending-a-message)

```
use MrRijal\LaravelSms\Facades\Sms;

Sms::to('9812345678')
    ->message('Hello from Laravel SMS')
    ->send();
```

When `sms.queue` is `true`, `send()` queues the message. To send immediately:

```
Sms::to('9812345678')
    ->message('Urgent message')
    ->sendNow();
```

### Using a specific provider

[](#using-a-specific-provider)

```
Sms::provider('twilio')
    ->to('9812345678')
    ->message('Hello from Twilio')
    ->send();
```

### Multiple recipients

[](#multiple-recipients)

```
Sms::to(['9812345678', '9800000000'])
    ->message('System maintenance tonight')
    ->send();
```

### Template messages

[](#template-messages)

```
Sms::to('9812345678')
    ->template('1207161789456789012', ['otp' => 123456])
    ->send();
```

`template()` takes a template ID and an array of variables. Supported where the driver implements it (e.g. MSG91, WhatsApp).

### Queued and scheduled sending

[](#queued-and-scheduled-sending)

```
// Queue and send when the worker runs
Sms::to('9812345678')->message('Queued SMS')->sendLater();

// Schedule for a specific time
Sms::to('9812345678')
    ->message('Scheduled SMS')
    ->sendLaterAt(now()->addMinutes(10));
```

### Random driver selection

[](#random-driver-selection)

Use the `random` provider to pick one of the configured drivers (e.g. for load balancing):

```
Sms::provider('random')
    ->to('9812345678')
    ->message('Sent via a random driver from config(random_drivers)')
    ->send();
```

Laravel Notifications
---------------------

[](#laravel-notifications)

Use the built-in SMS channel and notification class.

### Via `SmsNotification`

[](#via-smsnotification)

```
use MrRijal\LaravelSms\Notifications\SmsNotification;

$user->notify(new SmsNotification(message: 'Your order has been shipped'));

// With template
$user->notify(new SmsNotification(
    templateId: '1207161789456789012',
    variables: ['otp' => 456789]
));
```

### User model setup

[](#user-model-setup)

Add the `HasSms` trait and `routeNotificationForSms()`:

```
use MrRijal\LaravelSms\Traits\HasSms;

class User extends Authenticatable
{
    use HasSms;

    public function routeNotificationForSms(): string
    {
        return $this->phone;
    }
}
```

Then you can do:

```
$user->sms('Welcome to the app');
$user->sendSms('Password changed');
$user->smsTemplate('1207161789456789012', ['otp' => 987654]);
```

Events
------

[](#events)

The package dispatches:

EventWhen`SmsSending`Before the driver sends`SmsSent`After send (success/failure)Example listener:

```
use MrRijal\LaravelSms\Events\SmsSending;
use MrRijal\LaravelSms\Events\SmsSent;

Event::listen(SmsSending::class, function (SmsSending $event) {
    // Log, audit, or short-circuit sending
});

Event::listen(SmsSent::class, function (SmsSent $event) {
    if ($event->success) {
        // …
    } else {
        // $event->error …
    }
});
```

Macros
------

[](#macros)

Extend the `Sms` facade without editing the package:

```
use MrRijal\LaravelSms\Facades\Sms;

Sms::macro('sendOtp', function (string $number, int $otp) {
    return $this->to($number)
        ->template('OTP_TEMPLATE', ['otp' => $otp])
        ->sendNow();
});

Sms::sendOtp('9812345678', 123456);
```

Custom drivers
--------------

[](#custom-drivers)

1. Implement `MrRijal\LaravelSms\Contracts\SmsProvider`:

```
use MrRijal\LaravelSms\Contracts\SmsProvider;
use MrRijal\LaravelSms\SmsMessage;

class MySmsDriver implements SmsProvider
{
    public function __construct(protected array $config) {}

    public function send(SmsMessage $message): bool
    {
        // Use $message->getTo(), getText(), getTemplateId(), getVariables()
        return true;
    }
}
```

2. Register the driver and its config in `config/sms.php`:

```
'drivers' => [
    // …
    'mysms' => \App\Sms\MySmsDriver::class,
],
'providers' => [
    // …
    'mysms' => [
        'api_key' => env('MYSMS_API_KEY'),
    ],
],
```

3. Use it:

```
Sms::provider('mysms')
    ->to('9812345678')
    ->message('Hello from MySMS')
    ->sendNow();
```

Testing
-------

[](#testing)

Use the `fake` driver so no real SMS are sent:

```
Sms::provider('fake')
    ->to('9800000000')
    ->message('Test')
    ->sendNow();
```

In tests you can assert on `FakeDriver::$messages` and call `FakeDriver::reset()` between tests.

Run the test suite:

```
composer test
# or
vendor/bin/phpunit
```

### Continuous integration

[](#continuous-integration)

Pull requests and pushes to `main` run [GitHub Actions](https://github.com/mr-rijal/laravel-sms/actions): **Pint** (code style), **PHPStan** (Larastan), **PHPUnit** across PHP 8.2–8.4 with Laravel 11–13 (Laravel 13 runs on PHP 8.3+ only, per Laravel’s requirement), plus a **lowest-dependencies** sanity job.

Run the same checks locally:

```
composer ci
```

Changelog
---------

[](#changelog)

Please see [Releases](https://github.com/mr-rijal/laravel-sms/releases) for a changelog.

Contributing
------------

[](#contributing)

Contributions are welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover a security issue, please email  instead of opening an issue. See [SECURITY.md](SECURITY.md) for the full policy.

Credits
-------

[](#credits)

- [Prashant Rijal](https://github.com/mr-rijal)
- [All contributors](https://github.com/mr-rijal/laravel-sms/contributors)

Support
-------

[](#support)

If this package is useful to you, you can support its maintenance via [buymemomo.com/rijal](https://buymemomo.com/rijal).

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~80 days

Total

2

Last Release

43d ago

PHP version history (2 changes)1.0PHP ^8.4

1.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1bf3f09db608d82fb8ae800f0f738884fcd58f11bc6f1e2b11330ecb00d2528?d=identicon)[cart53](/maintainers/cart53)

---

Top Contributors

[![mr-rijal](https://avatars.githubusercontent.com/u/94687531?v=4)](https://github.com/mr-rijal "mr-rijal (11 commits)")[![mrthito](https://avatars.githubusercontent.com/u/49310993?v=4)](https://github.com/mrthito "mrthito (8 commits)")[![coderabbitai[bot]](https://avatars.githubusercontent.com/in/347564?v=4)](https://github.com/coderabbitai[bot] "coderabbitai[bot] (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mr-rijal-laravel-sms/health.svg)

```
[![Health](https://phpackages.com/badges/mr-rijal-laravel-sms/health.svg)](https://phpackages.com/packages/mr-rijal-laravel-sms)
```

###  Alternatives

[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
