PHPackages                             prgayman/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. [Mail &amp; Notifications](/categories/mail)
4. /
5. prgayman/laravel-sms

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

prgayman/laravel-sms
====================

Laravel package for sending SMS

16.4(1y ago)124.8k↓50%7MITPHPPHP ^7.3|^8.0

Since Jan 19Pushed 1y ago1 watchersCompare

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

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

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

[](#laravel-sms)

Laravel SMS allows you to send SMS from your Laravel application using multiple sms providers, allow to add custom sms provider

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

[](#requirements)

- php `^7.3|^8.0`
- guzzlehttp/guzzle `^7.0.1`

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

[](#installation)

To get the latest version of laravel-sms on your project, require it from "composer":

```
$ composer require prgayman/laravel-sms

```

Or you can add it directly in your composer.json file:

```
{
    "require": {
        "prgayman/laravel-sms": "1.5.0"
    }
}
```

### Laravel

[](#laravel)

Register the provider directly in your app configuration file config/app.php `config/app.php`:

Laravel &gt;= 5.5 provides package auto-discovery, thanks to rasmuscnielsen and luiztessadri who help to implement this feature in Zatca, the registration of the provider and the facades should not be necessary anymore.

```
'providers' => [
    Prgayman\Sms\SmsServiceProvider::class,
]
```

Add the facade aliases in the same file:

```
'aliases' => [
  'Sms' => Prgayman\Sms\Facades\Sms::class,
  'SmsHistory' => Prgayman\Sms\Facades\SmsHistory::class,
]
```

### Lumen

[](#lumen)

Register the provider in your bootstrap app file `boostrap/app.php`

Add the following line in the "Register Service Providers" section at the bottom of the file.

```
$app->register(Prgayman\Sms\SmsServiceProvider::class);
```

For facades, add the following lines in the section "Create The Application" .

```
class_alias(\Prgayman\Sms\Facades\Sms::class, 'Sms');
class_alias(\Prgayman\Sms\Facades\SmsHistory::class, 'SmsHistory');
```

Run Migrations
--------------

[](#run-migrations)

Publish the migrations with this artisan command:

```
$ php artisan vendor:publish --tag=laravel-sms-migrations

```

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

[](#configuration)

You can publish the config file with this artisan command:

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

```

Available SMS Providers
-----------------------

[](#available-sms-providers)

ProviderURLTestedMultiple contactsConfigJawalSmsYesYes[Click](docs/drivers_configuration.md#jawalsms)TaqnyatYesYes[Click](docs/drivers_configuration.md#taqnyat)NexmoYesNo[Click](docs/drivers_configuration.md#nexmo)TwilioYesNo[Click](docs/drivers_configuration.md#twilio)MoraSaYesYes[Click](docs/drivers_configuration.md#morasa)MsegatYesYes[Click](docs/drivers_configuration.md#msegat)KobikomYesYes[Click](docs/drivers_configuration.md#kobikom)UnifonicNoYes[Click](docs/drivers_configuration.md#unifonic)Jor MallYesNo[Click](docs/drivers_configuration.md#jor_mall)Available SMS Drivers local development
---------------------------------------

[](#available-sms-drivers-local-development)

ProviderMultiple contactsConfigarrayYes-logYes[Click](docs/drivers_configuration.md#log)Events
------

[](#events)

- `\Prgayman\Sms\Events\MessageSending::class`
- `\Prgayman\Sms\Events\MessageSent::class`
- `\Prgayman\Sms\Events\MessageFailed::class`

Types
-----

[](#types)

- `\Prgayman\Sms\SmsTypes::GENERAL`
- `\Prgayman\Sms\SmsTypes::OTP`
- `\Prgayman\Sms\SmsTypes::WELCOME`
- `\Prgayman\Sms\SmsTypes::AD`

Usage
-----

[](#usage)

### Set default driver

[](#set-default-driver)

#### Using `.env`

[](#using-env)

```
SMS_DRIVER=log
```

#### Using facades

[](#using-facades)

```
/**
 * Set the default sms driver name.
 *
 * @param string $driver
*/
Prgayman\Sms\Facades\Sms::setDefaultDriver("array");
```

### Enable sms history using database (send multiple contacts is not support store history)

[](#enable-sms-history-using-database-send-multiple-contacts-is-not-support-store-history)

- Enable the key `SMS_HISTORY_ENABLED` in `.env` file

    ```
    SMS_HISTORY_ENABLED=true
    ```
- Make sure publish the migrations with this artisan command:

    ```
    $ php artisan vendor:publish --tag=laravel-sms-migrations

    ```
- Run migrate with this artisan command:

    ```
    $ php artisan migrate

    ```

### Send Message

[](#send-message)

You can simply send a message like this:

```
# Send message using facade
use Prgayman\Sms\Facades\Sms;

$to = "+962790000000";
$from = "SenderName";
$message = "Test Send Message";

/**
 * Send using default driver sms
 *
 * @return \Prgayman\Sms\SmsDriverResponse
 */
$response = Sms::to($to)->from($from)->message($message)->send();

# Get Message
$response->getMessage();

# Get Request
$response->getRequest();

# Get driver response
$response->getResponse();

# Check is successfuly send sms message
$response->successful();

# Check is failed send sms message
$response->failed();
```

Send using select driver sms

```
Sms::driver("array")
  ->to($to)
  ->from($from)
  ->message($message)
  ->send();
```

Send multiple contacts

```
// please sure driver is support send multiple contacts
Sms::to([
  "+962792994123",
  "+962792994124",
  "+962792994125",
])
->from($from)
->message($message)
->send();
```

Send using custom type

```
Sms::driver("array")
  ->type(\Prgayman\Sms\SmsTypes::OTP)
  ->to($to)
  ->from($from)
  ->message($message)
  ->send();
```

Send multiple messages (run events and store history per message)

```
    $items = [
        [
            "to" => "+962792994123",
            "from" => "SenderName",
            "message" => "New message"
        ],
        [
            "to" => "+962792994124",
            "from" => "SenderName",
            "message" => "Send Message"
        ]
    ];

    /**
     * @param $items must contain message, to, and from keys per item
     * @return \Prgayman\sms\SmsDriverResponse[]
     */
    $response = Sms::sendArray($items);

    // Or send using helper function
    $response = sms()->sendArray($items);
```

Send using helper function with default driver

```
sms()
  ->to($to)
  ->from($from)
  ->message($message)
  ->send();
```

Send using helper function and select driver

```
sms("array")
  ->to($to)
  ->from($from)
  ->message($message)
  ->send();
```

Send using helper function and custom type

```
sms("array")
  ->type(\Prgayman\Sms\SmsTypes::OTP)
  ->to($to)
  ->from($from)
  ->message($message)
  ->send();
```

### Create custom driver

[](#create-custom-driver)

- Create class extends from `\Prgayman\Sms\Drivers\Driver` and handler send function
- if driver support send multiple contacts please implements from `Prgayman\Sms\Contracts\DriverMultipleContactsInterface`

    ```
    use Prgayman\Sms\Drivers\Driver;
    use Prgayman\Sms\SmsDriverResponse;
    use Prgayman\Sms\Contracts\DriverMultipleContactsInterface;

    class CustomDriver extends Driver implements DriverMultipleContactsInterface {

        # You not need to run events or store history
        # package automatically run all events and store history
        public function send() : SmsDriverResponse
        {

          $request = [
              "to" => $this->getTo(),
              'from' => $this->getFrom(),
              'body' => $this->getMessage(),
          ];

          try {
              # Handler send message
              $response = null;
              return new SmsDriverResponse($request, $response, true);
          } catch (\Exception $e) {
              return new SmsDriverResponse($request, null, false, $e->getMessage());
          }
        }

    }
    ```
- Add driver confg in `config/sms.php`

    ```
      "drivers"=>[
        .......

        # Use custom driver
        'your-driver-name'=>[
          'handler'=> \App\SmsDrivers\CustomDriver::class
        ],

        # Use supported drivers but different name
        # Copy driver object and change name
        "new-log-driver" => [
              "driver" => "log",
              'channel' => env('SMS_LOG_CHANNEL'),
        ],
      ]
    ```
- Send message with custom driver

    ```
    # Use driver
    Sms::driver("your-driver-name")
        ->to($to)
        ->from($from)
        ->message($message)
        ->send();

    # Or set custom driver in default driver or set
    # SMS_DRIVER=your-driver-name in dotenv file
    Sms::setDefaultDriver("your-driver-name");

    Sms::to($to)
      ->from($from)
      ->message($message)
      ->send();
    ```

Channel Usage
-------------

[](#channel-usage)

First you have to create your notification using `php artisan make:notification` command. then `Prgayman\Sms\Channels\SmsChannel::class` can be used as channel like the below:

```
use Illuminate\Notifications\Notification;
use Prgayman\Sms\SmsNotification;

class SendSmsNotification extends Notification
{

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['sms']; # add this channel
    }

    /**
     * @param mixed $notifiable
     * @return \Prgayman\Sms\SmsNotification
     */
    public function toSms($notifiable)
    {
        # Send message with default driver
        return (new SmsNotification)
          ->to("+962790000000")
          ->from("SenderName")
          ->message("Test New Message");

        # Send message with select driver
        return (new SmsNotification)
          ->driver('array')
          ->to("+962790000000")
          ->from("SenderName")
          ->message("Test New Message");
    }
}
```

SMS History
-----------

[](#sms-history)

```
use Prgayman\Sms\Facades\SmsHistory;

# Get all
$histories = SmsHistory::get();

# Use Filters all filter is optional
$histories = SmsHistory::recipients("+962790000000")
->senders(["SendName"])
->statuses([
  Prgayman\Sms\Models\SmsHistory::SUCCESSED,
  Prgayman\Sms\Models\SmsHistory::FAILED,
])
->drivers(["log","array"])
->driverNames(["custom_name"])
->get();

# Or can use helper function
$histories = smsHistory()
->recipients("+962790000000")
->senders(["SendName"])
->statuses([
  Prgayman\Sms\Models\SmsHistory::SUCCESSED,
  Prgayman\Sms\Models\SmsHistory::FAILED,
])
->drivers(["log","array"])
->driverNames(["custom_name"])
->get();
```

Testing
-------

[](#testing)

```
composer test
```

Licence
-------

[](#licence)

This library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~21 days

Total

19

Last Release

713d ago

Major Versions

1.6.3 → 16.42024-05-29

### Community

Maintainers

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

---

Top Contributors

[![prgayman](https://avatars.githubusercontent.com/u/62302022?v=4)](https://github.com/prgayman "prgayman (92 commits)")

---

Tags

jawalsmslaravelnexmosmstaqnyattwiliolaravelsmstwilionexmotaqnyatprgaymanjawalsmsmorasamsegatkobikomjormall

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[simplesoftwareio/simple-sms

Simple-SMS is a package made for Laravel to send/receive (polling/pushing) text messages. Currently supports CalLFire, EZTexting, Email Gateways, FlowRoute, LabsMobile, Mozeo, Nexmo, Plivo, Twilio, and Zenvia

20845.7k5](/packages/simplesoftwareio-simple-sms)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[mrabbani/laravel_infobip

Simple-SMS is a package made for Laravel to send/receive (polling/pushing) text messages. Currently supports CallFire, EZTexting, Email Gateways, Mozeo, and Twilio.

112.9k](/packages/mrabbani-laravel-infobip)

PHPackages © 2026

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