misaf/laravel-sms-gateway
Composer 安装命令:
composer require misaf/laravel-sms-gateway
包简介
Driver-based SMS gateway manager for Laravel.
关键字:
README 文档
README
A simple driver-based SMS gateway manager for Laravel.
Features
- Separate packages for each provider.
- Switch drivers per request.
- Laravel HTTP client access.
- SMS sent events with request and response data.
- Custom driver registration.
Requirements
- PHP 8.3+
- Laravel 13+
Installation
Install the core package:
composer require misaf/laravel-sms-gateway
Install one or more driver packages:
composer require misaf/laravel-sms-gateway-ghasedak
Publish the config file:
php artisan vendor:publish --tag=sms-gateway-config
Driver Packages
First-party driver packages:
| Driver | Package |
|---|---|
ghasedak |
misaf/laravel-sms-gateway-ghasedak |
ippanel |
misaf/laravel-sms-gateway-ippanel |
kavenegar |
misaf/laravel-sms-gateway-kavenegar |
magfa |
misaf/laravel-sms-gateway-magfa |
melipayamak |
misaf/laravel-sms-gateway-melipayamak |
messagebird |
misaf/laravel-sms-gateway-messagebird |
plivo |
misaf/laravel-sms-gateway-plivo |
smsir |
misaf/laravel-sms-gateway-smsir |
sunway |
misaf/laravel-sms-gateway-sunway |
textlocal |
misaf/laravel-sms-gateway-textlocal |
twilio |
misaf/laravel-sms-gateway-twilio |
vonage |
misaf/laravel-sms-gateway-vonage |
Quick Start
Install the Ghasedak driver package:
composer require misaf/laravel-sms-gateway-ghasedak
Set the default driver in .env:
SMS_GATEWAY_DRIVER=ghasedak # Default driver SMS_GATEWAY_GHASEDAK_APIKEY=your-api-key # Ghasedak API key
Add the matching service credentials in config/services.php:
'ghasedak' => [ 'api_key' => env('SMS_GATEWAY_GHASEDAK_APIKEY'), ],
Send through the default driver:
use Misaf\LaravelSmsGateway\Facade\SmsGateway; $response = SmsGateway::driver()->send([ 'message' => 'Hello', 'receptor' => '09123456789', ]);
See the original provider documentation for available fields.
Configuration
Set SMS_GATEWAY_DRIVER in your application's .env file to choose the default driver.
Provider environment keys are defined by each driver package — see that package's README (linked under Driver Packages) for its variables.
Switching Drivers
Use driver() to send through a specific driver without changing the default:
SmsGateway::driver('ghasedak')->send($data); SmsGateway::driver('kavenegar')->send($data);
HTTP Client Access
Use request() to send directly through the configured Laravel HTTP client for a driver:
$response = SmsGateway::driver('ghasedak') ->request() ->post('sms/send/simple', $data);
Use either send() or request() — after calling request()->post(...), you do not need to call send().
Events
HTTP drivers dispatch Misaf\LaravelSmsGateway\Events\SmsSent.
use Misaf\LaravelSmsGateway\Events\SmsSent; final class StoreSmsGatewayResult { public function handle(SmsSent $event): void { $driver = $event->driverName; $url = $event->request->url(); $status = $event->response->status(); $body = $event->response->json(); } }
Event properties:
$driverName: the resolved SMS gateway driver name.$request: theIlluminate\Http\Client\Requestinstance.$response: theIlluminate\Http\Client\Responseinstance.
Custom Drivers
Custom drivers should extend SmsGatewayDriver, implement send(), and use configureRequest() for driver-specific HTTP client options.
The driver name is taken from the extend() registration key; it selects the services.{name} config section and labels SmsSent events. Override driverName() only when those should use a different name.
namespace App\SmsGateways; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Response; use Misaf\LaravelSmsGateway\SmsGatewayDriver; final class CustomDriver extends SmsGatewayDriver { /** * @param array<string, mixed> $data */ public function send(array $data): Response { return $this->request()->post('messages', $data); } protected function defaultBaseUrl(): string { return 'https://api.example.com'; } protected function configureRequest(PendingRequest $request): PendingRequest { return $request->withToken($this->driverConfig('token')); } }
Register it from a service provider:
use App\SmsGateways\CustomDriver; use Illuminate\Contracts\Foundation\Application; use Illuminate\Support\ServiceProvider; use Misaf\LaravelSmsGateway\Facade\SmsGateway; final class AppServiceProvider extends ServiceProvider { public function boot(): void { SmsGateway::extend('custom', function (Application $app): CustomDriver { return $app->make(CustomDriver::class); }); } }
Testing
composer test
composer analyse
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
MIT
misaf/laravel-sms-gateway 适用场景与选型建议
misaf/laravel-sms-gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 07 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「gateway」 「messaging」 「notification」 「laravel」 「sms-gateway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 misaf/laravel-sms-gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 misaf/laravel-sms-gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 misaf/laravel-sms-gateway 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
PHP SDK for Mobile Message SMS API
Extensible library for building notifications and sending them via different delivery channels.
Azure service bus Transport
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 42
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-03