PHPackages                             misaf/laravel-sms-gateway - 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. misaf/laravel-sms-gateway

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

misaf/laravel-sms-gateway
=========================

Supercharge your Laravel applications with our seamless SMS Gateway integration!

v1.0.1(3mo ago)12MITPHPPHP ^8.3

Since Jan 27Pushed 3mo agoCompare

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

READMEChangelogDependencies (12)Versions (3)Used By (0)

Laravel SMS Gateway
===================

[](#laravel-sms-gateway)

A flexible and easy-to-use SMS gateway package for Laravel applications. This package provides a unified interface for sending SMS messages through multiple providers, making it simple to switch between different SMS services or use multiple providers simultaneously.

Features
--------

[](#features)

- 🚀 **Multiple Driver Support**: Built-in support for Ghasedak and Sunway SMS providers
- 🔌 **Extensible Architecture**: Easy to add custom SMS drivers
- 🎯 **Laravel Integration**: Seamless integration with Laravel's service container
- 📝 **Facade Support**: Clean and intuitive API using Laravel facades
- ⚙️ **Configuration Management**: Environment-based configuration
- 🔒 **Type Safe**: Built with strict types and modern PHP practices

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

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 10.0

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

[](#installation)

You can install the package via Composer:

```
composer require misaf/laravel-sms-gateway
```

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

[](#configuration)

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to your `config` directory:

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

Or manually publish the config file:

```
php artisan vendor:publish --provider="Misaf\LaravelSmsGateway\SmsGatewayServiceProvider"
```

### Environment Variables

[](#environment-variables)

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

```
# Default SMS Gateway Driver
SMS_GATEWAY_DRIVER=ghasedak

# Ghasedak Configuration
SMS_GATEWAY_GHASEDAK_APIKEY=your-api-key
SMS_GATEWAY_GHASEDAK_LINENUMBER=your-line-number

# Sunway Configuration
SMS_GATEWAY_SUNWAY_GATEWAY=https://sms.sunwaysms.com/smsws/HttpService.ashx
SMS_GATEWAY_SUNWAY_USERNAME=your-username
SMS_GATEWAY_SUNWAY_PASSWORD=your-password
SMS_GATEWAY_SUNWAY_SPECIALNUMBER=your-special-number
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Misaf\LaravelSmsGateway\Facade\SmsGateway;

// Send SMS using the default driver
SmsGateway::driver()->send()
    ->get('HttpService.ashx', [
        'method' => 'SendSMS',
        'mobile' => '09123456789',
        'message' => 'Hello, World!'
    ]);

// Use a specific driver
SmsGateway::driver('sunway')->send()
    ->get('HttpService.ashx', [
        'method' => 'SendSMS',
        'mobile' => '09123456789',
        'message' => 'Hello, World!'
    ]);
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Misaf\LaravelSmsGateway\SmsGatewayManager;

class SmsController extends Controller
{
    public function __construct(
        private SmsGatewayManager $smsGateway
    ) {}

    public function sendSms()
    {
        $this->smsGateway->driver()->send()
            ->get('HttpService.ashx', [
                'method' => 'SendSMS',
                'mobile' => '09123456789',
                'message' => 'Hello, World!'
            ]);
    }
}
```

### Using the Service Container

[](#using-the-service-container)

```
$smsGateway = app('sms-gateway');

$smsGateway->driver('ghasedak')->send()
    ->get('HttpService.ashx', [
        'method' => 'SendSMS',
        'mobile' => '09123456789',
        'message' => 'Hello, World!'
    ]);
```

Available Drivers
-----------------

[](#available-drivers)

### Ghasedak

[](#ghasedak)

The Ghasedak driver is configured with:

- `apiKey`: Your Ghasedak API key
- `linenumber`: Your Ghasedak line number

### Sunway

[](#sunway)

The Sunway driver is configured with:

- `gateway`: The Sunway SMS gateway URL
- `username`: Your Sunway username
- `password`: Your Sunway password
- `special_number`: Your Sunway special number

Creating Custom Drivers
-----------------------

[](#creating-custom-drivers)

To create a custom driver, implement the `SmsGatewayHandlerInterface`:

```
