PHPackages                             moffhub/sms-handler - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. moffhub/sms-handler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

moffhub/sms-handler
===================

Unified SMS gateway for Laravel with multi-provider support (Advanta, Africa's Talking, Twilio, Nexmo, Onfon). Queue-ready, delivery tracking, fallback chains, templating, and analytics.

v0.1.2(1mo ago)02.4k↓46.5%MITPHPPHP ^8.4|^8.5CI passing

Since Sep 4Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Moffhub-Solutions/sms-handler)[ Packagist](https://packagist.org/packages/moffhub/sms-handler)[ Docs](https://github.com/moffhub/sms-handler)[ RSS](/packages/moffhub-sms-handler/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (22)Used By (0)

SMS Handler
-----------

[](#sms-handler)

[![Latest Version on Packagist](https://camo.githubusercontent.com/75f5df23d58efaf8218627cb3b6e5242358c12ffcb50998eae1552a2dda38015/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f66666875622f736d732d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moffhub/sms-handler)[![Total Downloads](https://camo.githubusercontent.com/3a1b3c422d5a9f69f6df29ed49a9106c466662d6873eacdf2e8b247fa5c09701/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f66666875622f736d732d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moffhub/sms-handler)

A simple, unified SMS integration library for Laravel. Send SMS messages through multiple providers with a consistent API.

Features
--------

[](#features)

- Send SMS
- Send Scheduled SMS
- Send Bulk SMS
- Log SMS messages (database or file)
- Multiple provider support
- Custom provider extensibility

Supported Providers
-------------------

[](#supported-providers)

- **Advanta** - Kenya SMS gateway
- **Africa's Talking** - Pan-African SMS gateway
- **Twilio** - Global SMS provider
- **Nexmo/Vonage** - Global SMS provider
- **Onfon Media** - Kenya SMS gateway
- **Custom** - Build your own provider

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

[](#installation)

```
composer require moffhub/sms-handler
```

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

[](#configuration)

Publish the config and migrations:

```
php artisan vendor:publish --provider="Moffhub\SmsHandler\SmsHandlerServiceProvider" --tag=config
php artisan vendor:publish --tag=migrations
php artisan migrate
```

### Environment Variables

[](#environment-variables)

Add the following to your `.env` file based on your provider:

```
# Provider selection
SMS_PROVIDER=at  # Options: advanta, at, onfon, twilio, nexmo

# Africa's Talking
AT_USERNAME=sandbox          # Use 'sandbox' for testing, your app username for production
AT_API_KEY=your_api_key
AT_FROM=YOUR_SENDER_ID       # Optional: Your registered sender ID/short code
AT_API_URL=                  # Optional: Custom API URL (auto-detected based on username)

# Advanta
ADVANTA_API_KEY=
ADVANTA_API_URL=
ADVANTA_BULK_API_URL=
ADVANTA_PARTNER_ID=
ADVANTA_SHORT_CODE=

# Onfon Media
ONFON_API_KEY=
ONFON_API_URL=
ONFON_SENDER_ID=
ONFON_CLIENT_ID=

# Nexmo/Vonage
NEXMO_KEY=
NEXMO_SECRET=
NEXMO_FROM=NEXMO
NEXMO_API_URL=https://rest.nexmo.com/sms/json

# Twilio
TWILIO_SID=
TWILIO_TOKEN=
TWILIO_FROM=
TWILIO_API_URL=https://api.twilio.com

# Logging
SMS_LOG_CHANNEL=log  # Options: log, model
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Moffhub\SmsHandler\Facades\Sms;

// Send a single SMS
Sms::sendSms('+254712345678', 'Hello World');

// Send bulk SMS
Sms::sendBulkSms(['+254712345678', '+254712345679'], 'Hello everyone!');

// Send scheduled SMS
Sms::sendScheduledSms('+254712345678', 'Reminder!', '2024-12-25 09:00:00');

// Check delivery status
$status = Sms::getSmsDeliveryStatus('message_id_here');
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Moffhub\SmsHandler\Services\SmsService;

class NotificationController extends Controller
{
    public function __construct(protected SmsService $smsService) {}

    public function notify(Request $request)
    {
        $this->smsService->sendSms(
            $request->phone,
            $request->message
        );
    }
}
```

### Switching Providers at Runtime

[](#switching-providers-at-runtime)

```
use Moffhub\SmsHandler\SmsManager;

$manager = app(SmsManager::class);

// Use Africa's Talking for this message
$manager->driver('at')->sendSms('+254712345678', 'Via AT');

// Use Twilio for this message
$manager->driver('twilio')->sendSms('+1234567890', 'Via Twilio');
```

Africa's Talking Integration
----------------------------

[](#africas-talking-integration)

The library fully supports the [Africa's Talking Bulk SMS API](https://developers.africastalking.com/docs/sms/sending/bulk):

### Sandbox Testing

[](#sandbox-testing)

```
AT_USERNAME=sandbox
AT_API_KEY=your_sandbox_api_key
```

### Production

[](#production)

```
AT_USERNAME=your_app_username
AT_API_KEY=your_production_api_key
AT_FROM=YOUR_SENDER_ID
```

### Features

[](#features-1)

- Automatic sandbox/production URL detection
- Phone number formatting (supports 0712..., 254712..., +254712...)
- Bulk SMS with enqueue support
- Sender ID/Short code support
- Detailed response handling with message IDs and costs

Custom Providers
----------------

[](#custom-providers)

Create your own provider by extending `CustomProvider`:

```
use Moffhub\SmsHandler\Providers\CustomProvider;
use Illuminate\Support\Collection;

class MySmsProvider extends CustomProvider
{
    protected function getApiUrl(): string
    {
        return 'https://api.custom.com/send';
    }

    protected function buildPayload(string $to, string $message): array
    {
        return [
            'to' => $to,
            'text' => $message,
            'api_key' => $this->config['key'],
        ];
    }

    protected function handleResponse(mixed $response): ?Collection
    {
        return collect([
            'status' => $response['status'] ?? 'unknown',
        ]);
    }
}
```

Register your provider:

```
// In a service provider
use Moffhub\SmsHandler\SmsManager;

$this->app->make(SmsManager::class)->extend('custom', function ($app) {
    return new MySmsProvider([
        'key' => config('sms.providers.custom.key'),
    ]);
});
```

Add config:

```
// config/sms.php
'providers' => [
    'custom' => [
        'key' => env('MY_CUSTOM_API_KEY'),
    ],
],
```

Update `.env`:

```
SMS_PROVIDER=custom
MY_CUSTOM_API_KEY=super-secret
```

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

[](#laravel-notifications)

Use SMS in Laravel notifications:

```
use Moffhub\SmsHandler\Notifications\SmsChannel;

class OrderShipped extends Notification
{
    public function via($notifiable): array
    {
        return [SmsChannel::class];
    }

    public function toSms($notifiable): string
    {
        return 'Your order has been shipped!';
    }
}
```

Ensure your notifiable model has a `routeNotificationForSms` method:

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

Logging
-------

[](#logging)

SMS messages can be logged to file or database:

```
# Log to Laravel's log file
SMS_LOG_CHANNEL=log

# Log to database (requires migration)
SMS_LOG_CHANNEL=model
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance84

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~32 days

Recently: every ~26 days

Total

19

Last Release

51d ago

PHP version history (4 changes)0.0.1PHP ^8.3

v0.0.12PHP ^8.3|^8.4

v0.1.0PHP ^8.3|^8.4|^8.5

v0.1.2PHP ^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b5c3549bf8f8bab163b760fe2023fe357a3c85ed366e052a735ff5c50f84518?d=identicon)[Moffrough](/maintainers/Moffrough)

---

Top Contributors

[![MOFFROUGH](https://avatars.githubusercontent.com/u/20206597?v=4)](https://github.com/MOFFROUGH "MOFFROUGH (66 commits)")

---

Tags

laravellaravel-packagesmstwiliovonagebulk-smssms-gatewaynexmoAfricastalkingafricasms providersms notificationadvantaonfondelivery-reportsms-template

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/moffhub-sms-handler/health.svg)

```
[![Health](https://phpackages.com/badges/moffhub-sms-handler/health.svg)](https://phpackages.com/packages/moffhub-sms-handler)
```

###  Alternatives

[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k2.9M21](/packages/realrashid-sweet-alert)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10138.4k](/packages/gr8shivam-laravel-sms-api)[imanghafoori/laravel-nullable

A package to help you write expressive defensive code in a functional manner

151423.7k6](/packages/imanghafoori-laravel-nullable)[prgayman/laravel-sms

Laravel package for sending SMS

124.8k](/packages/prgayman-laravel-sms)

PHPackages © 2026

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