jishanhoshen/laravel-sms

Simple SMS sending service for Laravel apps, using a masking SMS gateway.

Maintainers

Package info

github.com/jishanhoshen/laravel-sms

pkg:composer/jishanhoshen/laravel-sms

Transparency log

Statistics

Installs: 10

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-08-12 09:38 UTC

This package is auto-updated.

Last update: 2026-08-13 10:57:36 UTC


README

Multi-provider SMS sending for Laravel apps. Send through whichever gateway is configured as default (SMS_PROVIDER in .env), or pick a specific provider at call time — the rest of your app's code never changes.

Built-in providers:

Key Gateway
shiramsystem ShiramSystem (your current masking SMS gateway)
twilio Twilio Programmable Messaging
alpha_sms Alpha SMS / sms.net.bd

Install

From a private/local path (no Packagist needed yet)

In each project's composer.json:

"repositories": [
    { "type": "path", "url": "../packages/laravel-sms" }
]
composer require jishanhoshen/laravel-sms:@dev

From a private VCS (GitHub repo)

"repositories": [
    { "type": "vcs", "url": "https://github.com/jishanhoshen/laravel-sms" }
]
composer require jishanhoshen/laravel-sms

Setup

Publish the config:

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

Pick the default provider and fill in only that provider's credentials in .env:

SMS_PROVIDER=shiramsystem
SMS_COUNTRY_CODE=88

# shiramsystem
SHIRAMSYSTEM_URL=your-gateway-host.com
SHIRAMSYSTEM_EMAIL=your-email
SHIRAMSYSTEM_PASSWORD=your-password
SHIRAMSYSTEM_MASK=YourMask

# twilio
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM=

# alpha_sms
ALPHA_SMS_API_KEY=

You only need to fill in credentials for the provider(s) you actually use.

Usage

Default provider, via facade:

use JishanHoshen\LaravelSms\Facades\Sms;

Sms::send('Your OTP is 1234', '01712345678');

Explicit provider, one-off:

Sms::provider('twilio')->send('Your OTP is 1234', '01712345678');
Sms::provider('alpha_sms')->send('Your OTP is 1234', '01712345678');

Via dependency injection (uses the default provider):

use JishanHoshen\LaravelSms\Contracts\SmsServiceInterface;

class SomeController
{
    public function __construct(protected SmsServiceInterface $sms) {}

    public function notify()
    {
        $this->sms->send('Your OTP is 1234', '01712345678');
    }
}

Via the container directly:

app('sms')->provider('twilio')->send('Hello', '01712345678');

Adding a new provider

  1. Create a class implementing JishanHoshen\LaravelSms\Contracts\SmsServiceInterface (just one method: send(string $message, string $number): bool).
  2. Add its config block under providers in config/sms.php.
  3. Register it — either add it to SmsManager::$providerMap, or from your app's own service provider:
app('sms')->extend('my_gateway', \App\Sms\MyGatewayProvider::class);

No existing code (controllers, jobs, etc.) needs to change when you add or swap providers — they only ever depend on SmsServiceInterface or the Sms facade.

Notes

  • Pass the local number without the country code (e.g. 01712345678); each provider's country_code config (default 88) is prepended automatically.
  • Every send attempt and its result is logged via Laravel's Log facade, prefixed with the provider name (e.g. [Twilio] SMS sent successfully).
  • Twilio and Alpha SMS integrations here call their REST APIs directly over HTTP (no extra SDK dependency) — verify against their current docs before production use, since gateway APIs can change.