PHPackages                             rayzenai/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. [HTTP &amp; Networking](/categories/http)
4. /
5. rayzenai/laravel-sms

ActiveLibrary[HTTP &amp; Networking](/categories/http)

rayzenai/laravel-sms
====================

A Laravel package for sending SMS messages with support for both string and bigint phone fields

3.0.1(7mo ago)0293MITPHPPHP ^8.2

Since Jul 16Pushed 7mo agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (10)Used By (0)

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

[](#laravel-sms)

A comprehensive Laravel package for sending SMS messages through various providers with Filament admin panel integration.

Features
--------

[](#features)

- 📱 Send single and bulk SMS messages
- 🔄 Multiple SMS provider support (HTTP, Twilio, SwiftSMS, etc.)
- 📊 Filament admin panel integration for SMS management
- 👥 User selection for bulk SMS - send to existing users in your database
- 🔍 Automatic duplicate phone number detection and handling
- 📝 SMS logs and tracking
- ⚡ Rate limiting and retry mechanisms
- 🛡️ Built-in error handling and logging
- 🇳🇵 Nepali phone number validation
- 📦 Bulk SMS optimization with provider-specific batch sending
- ✨ Modern UI with improved toggles and form layout

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 12.0 or higher
- Filament 4.0 (for admin panel features)

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

[](#installation)

You can install the package via composer:

```
composer require rayzenai/laravel-sms
```

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

[](#configuration)

### Step 1: Publish Configuration

[](#step-1-publish-configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Rayzenai\LaravelSms\LaravelSmsServiceProvider" --tag="config"
```

This will publish a `laravel-sms.php` configuration file to your `config` directory.

### Step 2: Run Migrations

[](#step-2-run-migrations)

Run the migrations to create the necessary database tables:

```
php artisan migrate
```

### Step 3: Configure Environment Variables

[](#step-3-configure-environment-variables)

Add the following variables to your `.env` file:

```
# SMS Provider Configuration
SMS_PROVIDER=http
SMS_API_BASE_URL=https://api.your-sms-provider.com
SMS_API_KEY=your-api-key-here
SMS_DEFAULT_SENDER="Your App Name"

# Optional: Logging Configuration
SMS_LOGGING_ENABLED=true
SMS_LOG_CHANNEL=stack

# Optional: Rate Limiting
SMS_RATE_LIMIT_ENABLED=true
SMS_MAX_PER_MINUTE=60
SMS_MAX_PER_HOUR=1000

# Optional: Retry Configuration
SMS_RETRY_ATTEMPTS=3
SMS_RETRY_DELAY=1000

# SwiftSMS Provider Configuration (for Nepal)
SMS_PROVIDER=swift
SWIFT_SMS_ORGANISATION_CODE=your-org-code
SWIFT_SMS_USERNAME=your-username
SWIFT_SMS_PASSWORD=your-password
```

### Step 4: Configure User Model Integration (Optional)

[](#step-4-configure-user-model-integration-optional)

If you want to enable sending SMS to users from your database, update the config file:

```
// config/laravel-sms.php
'user_model' => [
    'enabled' => true,
    'class' => \App\Models\User::class,
    'phone_field' => 'phone', // The field that contains the phone number
    'name_field' => 'name',   // The field to display as user name
],
```

Usage
-----

[](#usage)

### Phone Number Validation

[](#phone-number-validation)

The package now supports validation for Nepali phone numbers:

- Numbers must start with +977
- Must have 10 digits after the country code (e.g., +977 9801002468)

#### Example Validation Rule:

[](#example-validation-rule)

```
'phone' => 'required|string|regex:/^\+977[9][0-9]{9}$/'
```

### Basic Usage

[](#basic-usage)

#### Sending a Single SMS

[](#sending-a-single-sms)

```
use Rayzenai\LaravelSms\Services\SmsService;
use Rayzenai\LaravelSms\Facades\Sms;

// Method 1: Using the Facade with fluent interface (recommended)
$sentMessage = Sms::to('+9779801002468')
    ->message('Hello from Laravel SMS!')
    ->send();

// Method 2: Using the Facade with direct method call
$sentMessage = Sms::send('+9779801002468', 'Hello from Laravel SMS!');

// Method 3: Using dependency injection
public function sendSms(SmsService $smsService)
{
    try {
        $sentMessage = $smsService->send('+1234567890', 'Hello from Laravel SMS!');

        // Access sent message details
        echo "Message ID: " . $sentMessage->provider_message_id;
        echo "Status: " . $sentMessage->status;
    } catch (\Exception $e) {
        // Handle error
        Log::error('SMS sending failed: ' . $e->getMessage());
    }
}

// Method 3: Using service container
$smsService = app(SmsService::class);
$sentMessage = $smsService->send('+1234567890', 'Your message here');
```

#### Sending Bulk SMS

[](#sending-bulk-sms)

```
use Rayzenai\LaravelSms\Facades\Sms;
use Rayzenai\LaravelSms\Services\SmsService;

// Method 1: Using the Facade with fluent interface (recommended)
$recipients = [
    '+9779801002468',
    '+9779812345678',
    '+9779898765432'
];

$sentMessages = Sms::to($recipients)
    ->message('Bulk message to all recipients!')
    ->sendBulk();

// Method 2: Using the service directly
$smsService = app(SmsService::class);

try {
    $sentMessages = $smsService->sendBulk($recipients, 'Bulk message to all recipients!');

    foreach ($sentMessages as $message) {
        echo "Recipient: {$message->recipient} - Status: {$message->status}\n";
    }
} catch (\Exception $e) {
    Log::error('Bulk SMS failed: ' . $e->getMessage());
```

### Using in Controllers

[](#using-in-controllers)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Rayzenai\LaravelSms\Services\SmsService;

class NotificationController extends Controller
{
    private SmsService $smsService;

    public function __construct(SmsService $smsService)
    {
        $this->smsService = $smsService;
    }

    public function sendWelcomeSms(Request $request)
    {
        $request->validate([
            'phone' => 'required|string|regex:/^\+977[9][0-9]{9}$/',
            'name' => 'required|string'
        ]);

        try {
            $message = "Welcome {$request->name}! Thank you for joining us.";
            $sentMessage = $this->smsService->send($request->phone, $message);

            return response()->json([
                'success' => true,
                'message_id' => $sentMessage->provider_message_id
            ]);
        } catch (\Exception $e) {
            return response()->json([
                'success' => false,
                'error' => 'Failed to send SMS'
            ], 500);
        }
    }
}
```

API Endpoints
-------------

[](#api-endpoints)

The package provides the following API endpoints:

### Send Single SMS

[](#send-single-sms)

**Endpoint:** `POST /api/sms/send`

**Request Body:**

```
{
    "recipient": "+1234567890",
    "message": "Your SMS message here"
}
```

**Response:**

```
{
    "success": true,
    "data": {
        "id": 1,
        "recipient": "+1234567890",
        "message": "Your SMS message here",
        "status": "sent",
        "provider_message_id": "SMS123456",
        "sent_at": "2024-01-01T12:00:00Z"
    }
}
```

### Send Bulk SMS

[](#send-bulk-sms)

**Endpoint:** `POST /api/sms/send-bulk`

**Request Body:**

```
{
    "recipients": ["+1234567890", "+0987654321"],
    "message": "Bulk SMS message"
}
```

**Response:**

```
{
    "success": true,
    "data": [
        {
            "recipient": "+1234567890",
            "status": "sent",
            "provider_message_id": "SMS123456"
        },
        {
            "recipient": "+0987654321",
            "status": "sent",
            "provider_message_id": "SMS123457"
        }
    ]
}
```

Filament Integration
--------------------

[](#filament-integration)

### Step-by-Step Filament Setup

[](#step-by-step-filament-setup)

#### 1. Install Filament (if not already installed)

[](#1-install-filament-if-not-already-installed)

```
composer require filament/filament:"^4.0"
php artisan filament:install --panels
```

#### 2. Register the SMS Plugin

[](#2-register-the-sms-plugin)

In Filament v4, you'll need to register the `LaravelSmsPlugin` in your `Panel` service provider:

```
use Rayzenai\LaravelSms\LaravelSmsPlugin;

// In app/Providers/Filament/AdminPanelProvider.php or your panel provider:
public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->plugins([
            LaravelSmsPlugin::make(),
        ]);
}
```

#### 3. Access the SMS Management

[](#3-access-the-sms-management)

Once you have registered the plugin, you will see a "Send SMS" section in the admin panel navigation.

1. Navigate to your Filament admin panel (typically `/admin`)
2. Look for the "Send SMS" and "Sent Messages" options under "SMS Management"
3. From here you can send SMS, view all sent messages, and filter the logs.

#### Filament Features:

[](#filament-features)

**Send SMS Page:**

- Single SMS sending with phone number validation
- Bulk SMS sending to multiple recipients
- **NEW: User selection mode for bulk SMS**
    - Select users from your database
    - Automatic duplicate phone number detection
    - Shows which users share the same phone number
    - "Select All" option for all unique phone numbers
    - Displays count of unique numbers vs total users
- Real-time character count for messages (160 character limit)
- Toggle between single and bulk SMS modes
- Toggle between manual entry and user selection (for bulk mode)
- Nepali phone number validation (+977 format)
- Confirmation dialogs before sending
- Success/error notifications
- Modern UI with clean sections and better visual hierarchy

**Sent Messages Resource:**

- View all sent SMS messages in a table
- Filter by status (pending, sent, failed, delivered)
- Filter by date range
- Search by recipient or message content
- View detailed SMS information
- Bulk delete functionality
- Export SMS logs

### Customizing Filament Resources

[](#customizing-filament-resources)

If you need to customize the Filament resources, you can publish them:

```
php artisan vendor:publish --provider="Rayzenai\LaravelSms\LaravelSmsServiceProvider" --tag="filament-resources"
```

Then modify the published resources in `app/Filament/Resources/SentMessageResource.php`.

Advanced Configuration
----------------------

[](#advanced-configuration)

### Using Multiple SMS Providers

[](#using-multiple-sms-providers)

You can configure multiple SMS providers in `config/laravel-sms.php`:

```
'providers' => [
    'twilio' => [
        'class' => \Rayzenai\LaravelSms\Providers\TwilioProvider::class,
        'account_sid' => env('TWILIO_ACCOUNT_SID'),
        'auth_token' => env('TWILIO_AUTH_TOKEN'),
        'from_number' => env('TWILIO_FROM_NUMBER'),
    ],
    'http' => [
        'class' => \Rayzenai\LaravelSms\Providers\HttpProvider::class,
        'api_key' => env('SMS_API_KEY'),
        'api_url' => env('SMS_API_BASE_URL'),
    ],
    'swiftsms' => [
        'class' => \Rayzenai\LaravelSms\Providers\SwiftSmsProvider::class,
        'api_url' => env('SWIFT_SMS_API_URL'),
        'username' => env('SWIFT_SMS_USERNAME'),
        'password' => env('SWIFT_SMS_PASSWORD'),
        'from' => env('SWIFT_SMS_FROM'),
    ],
],
```

### Rate Limiting

[](#rate-limiting)

Rate limiting is enabled by default. Configure it in your `.env`:

```
SMS_RATE_LIMIT_ENABLED=true
SMS_MAX_PER_MINUTE=60
SMS_MAX_PER_HOUR=1000
```

### Logging

[](#logging)

All SMS activities are logged when enabled:

```
SMS_LOGGING_ENABLED=true
SMS_LOG_CHANNEL=sms
```

You can create a custom log channel in `config/logging.php`:

```
'channels' => [
    // ...
    'sms' => [
        'driver' => 'daily',
        'path' => storage_path('logs/sms.log'),
        'level' => 'info',
        'days' => 14,
    ],
],
```

Creating Custom SMS Providers
-----------------------------

[](#creating-custom-sms-providers)

To create a custom SMS provider, implement the `SmsProviderInterface`:

```
namespace App\Sms\Providers;

use Rayzenai\LaravelSms\Providers\SmsProviderInterface;

class CustomProvider implements SmsProviderInterface
{
    public function send(string $to, string $message, ?string $from = null): array
    {
        // Your implementation here
        return [
            'status' => 'sent',
            'sid' => 'unique-message-id',
            'response' => []
        ];
    }

    public function sendBulk(array $recipients, string $message, ?string $from = null): array
    {
        // Your bulk implementation here
        $results = [];
        foreach ($recipients as $recipient) {
            $results[] = [
                'recipient' => $recipient,
                'status' => 'sent',
                'sid' => 'unique-message-id-' . uniqid(),
                'response' => []
            ];
        }
        return $results;
    }
}
```

Then register it in your configuration:

```
'providers' => [
    'custom' => [
        'class' => \App\Sms\Providers\CustomProvider::class,
    ],
],
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Rayzen AI](https://github.com/rayzenai)

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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 ~9 days

Recently: every ~17 days

Total

9

Last Release

232d ago

Major Versions

v1.2.3 → v2.0.02025-09-10

v2.0.0 → v3.0.02025-09-10

PHP version history (2 changes)v1.0.0PHP ^8.0

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/351e3224dcfda5f2fc1a86fb6424f60a9a060a39c938c6338a244d01912e077d?d=identicon)[kiran1991](/maintainers/kiran1991)

---

Top Contributors

[![Namrata199](https://avatars.githubusercontent.com/u/71477150?v=4)](https://github.com/Namrata199 "Namrata199 (5 commits)")

---

Tags

httplaravelnotificationsmstwiliomessaging

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[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)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[laragear/json

Easily retrieve and manipulate `Json` across your application.

363.5k](/packages/laragear-json)

PHPackages © 2026

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