bankola/laravel-multi-sms
Composer 安装命令:
composer require bankola/laravel-multi-sms
包简介
A multi-provider SMS package for Laravel with failover support.
README 文档
README
A robust, extensible, driver-based SMS package for Laravel. Send SMS via multiple providers (Twilio, Vonage, etc.) with built-in failover support, queuing, and easy testing.
Features
- Multi-Driver Support: Easily switch between providers (Twilio, Vonage, Log, etc.).
- Failover Logic: Automatically try fallback providers if the primary one fails.
- Queue Support: Seamless integration with Laravel Queues for background sending.
- Event-Driven: Dispatches events for sending, sent, and failed messages.
- Testing Fakes: Simple assertions for unit testing your SMS logic.
- Extensible: Add custom drivers with ease.
Installation
You can install the package via composer:
composer require bankola/laravel-multi-sms
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="sms-config"
This will create a config/sms.php file. You should configure your drivers and credentials in your .env file:
SMS_DRIVER=failover TWILIO_SID=your_sid TWILIO_TOKEN=your_token TWILIO_FROM=your_phone_number VONAGE_KEY=your_key VONAGE_SECRET=your_secret VONAGE_FROM=your_brand_name SMS_LOG_CHANNEL=stack
Usage
Sending an SMS
use Bankola\MultiSms\Facades\Sms; use Bankola\MultiSms\DTO\SmsMessage; Sms::send(new SmsMessage( to: '+1234567890', body: 'Your OTP is 1234' ));
Using a Specific Driver
Sms::driver('twilio')->send($message);
Queuing an SMS
Sms::queue($message); // Or specifying a driver for the queue Sms::queue($message, 'vonage');
Drivers
Log Driver
The log driver is perfect for local development. It writes the contents of the SMS to your Laravel logs.
Twilio Driver
Requires twilio/sdk. Configure TWILIO_SID, TWILIO_TOKEN, and TWILIO_FROM in your .env.
Vonage Driver
Requires vonage/client. Configure VONAGE_KEY, VONAGE_SECRET, and VONAGE_FROM in your .env.
Failover Driver
The failover driver iterates through a list of drivers until one successfully sends the message.
'failover' => [ 'driver' => 'failover', 'drivers' => ['twilio', 'vonage', 'log'], ],
Events
The package dispatches the following events:
Bankola\MultiSms\Events\SmsSending: Before a message is sent.Bankola\MultiSms\Events\SmsSent: After a message is successfully sent.Bankola\MultiSms\Events\SmsFailed: When a message fails to send.
Testing
Use the fake() method to mock SMS sending in your tests:
use Bankola\MultiSms\Facades\Sms; public function test_it_sends_an_sms() { Sms::fake(); // ... run your code ... Sms::assertSent(function ($message) { return $message->to === '+1234567890' && str_contains($message->body, 'OTP'); }); }
Extending
You can register custom drivers using the extend method in your AppServiceProvider:
use Bankola\MultiSms\Facades\Sms; Sms::extend('custom_provider', function ($app, $config) { return new CustomSmsDriver($config); });
The custom driver must implement Bankola\MultiSms\Contracts\SmsDriverInterface.
License
The MIT License (MIT). Please see License File for more information.
bankola/laravel-multi-sms 适用场景与选型建议
bankola/laravel-multi-sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「twilio」 「laravel」 「vonage」 「multi-provider」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bankola/laravel-multi-sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bankola/laravel-multi-sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bankola/laravel-multi-sms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Componente para integração com serviços de mensageria com APIs externas como Twilio, SendGrid, AWS SES, etc.
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
Alfabank REST API integration
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-24