Looking to hire Laravel developers? Try LaraJobs

laravel-sms maintained by fbpkg

Description
A simple and flexible SMS package for Laravel.
Last update
2026/09/21 19:43 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Laravel SMS

A simple and flexible SMS package for Laravel with support for multiple SMS gateways.

Requirements

  • PHP 8.2+
  • Laravel 11, 12, or 13
  • Guzzle 7.9+ or 8.0+

Installation

Install the package via Composer:

composer require fbpkg/laravel-sms

The package registers its service provider automatically through Laravel package discovery.

Configuration

Publish the configuration file:

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

The configuration file will be available at:

config/sms.php

Environment Variables

SMS_GATEWAY=ippanel

IPPANEL_KEY=
IPPANEL_FROM=
IPPANEL_URL=

IPPANEL_URL is optional. When it is not configured, the IPPanel gateway uses its default API URL.

Usage

Send SMS

use Fbpkg\Sms\Facades\Sms;

$response = Sms::to('+989120000000')
    ->message('Hello from Laravel!')
    ->send();

Send Pattern SMS

$response = Sms::to('+989120000000')
    ->pattern('pattern_code')
    ->params([
        'variable_name' => 'variable_value',
    ])
    ->send();

Select a Gateway

A gateway can be selected before sending the message:

$response = Sms::to('+989120000000')
    ->message('Hello!')
    ->gateway('ippanel')
    ->send();

The gateway can also be selected at the beginning:

$response = Sms::gateway('ippanel')
    ->to('+989120000000')
    ->message('Hello!')
    ->send();

If no gateway is specified, the gateway configured as default_gateway will be used.

Phone Numbers

Recipients are normalized to E.164 format before being sent to the gateway and written to the log.

Iranian mobile numbers can be provided in common formats, including Persian and Arabic-Indic digits:

09120000000
9120000000
989120000000
+989120000000
۰۹۱۲۰۰۰۰۰۰۰

All valid inputs are normalized to:

+989120000000

Response

SMS operations return an SmsResponse instance:

$response->successful;
$response->data;
$response->response;

For example:

if ($response->successful) {
    // SMS sent successfully.
}

The data property contains the raw response data returned by the selected gateway.

Logging

SMS logging can be configured in config/sms.php:

'logging' => [
    'enabled' => true,

    'levels' => [
        'info' => true,
        'warning' => true,
        'error' => true,
    ],

    'context' => [
        'driver' => true,
        'recipient' => true,
        'message' => true,
        'pattern' => true,
        'params' => true,
        'response' => false,
    ],
],

Logging uses Laravel's configured logging system.

By default, successful messages are logged with the driver, normalized recipient, and message. Pattern messages are logged with the driver, normalized recipient, pattern, and parameters.

The gateway response can also be included by enabling logging.context.response. Logging can be disabled entirely with logging.enabled.

Gateways

Currently supported gateways:

  • IPPanel

The package is designed to support additional SMS gateways through the SmsGateway contract.

License

The MIT License (MIT). Please see the License File for more information.

Version

Current version: 0.1.0