sujonmia/laravel-sms
最新稳定版本:v2.0.0
Composer 安装命令:
composer require sujonmia/laravel-sms
包简介
Laravel multi-provider SMS package (BulkSMSBD, Twilio, Arena, Elitbuzz)
关键字:
README 文档
README
A flexible Laravel SMS package that supports multiple SMS gateways like BulkSMSBD, Twilio, Arena, and Elitbuzz.
It allows sending SMS using a default sender or a custom sender dynamically per message.
Features
-
Multiple SMS Gateway Support
Supports bangladeshi and internatonal gateways like BulkSMSBD, Arena, Elitbuzz, and Twilio. -
Centralized Configuration Manage provider credentials from .env Switch default provider with SMS_GATEWAY
-
Auto Logging All SMS requests stored in sms_logs table
-
Event Driven
SmsSentevent fired after successful sendSmsFailedevent fired if provider fails -
Dynamic Sender ID
Callsender()to set a custom sender per message, overriding the default config. -
Default Sender Support
Ifsender()is not called, the package automatically uses thesender_idfrom the config file. -
Facade for Clean Syntax
UseSMS::send()orSMS::sender()->send()anywhere in your Laravel app. -
Extensible Architecture
Add new gateways easily by implementingGatewayInterfaceand updatingSMSService. -
Consistent API Responses
Returns standardized array responses with success or error details. -
Laravel Config Integration
All gateway credentials, URLs, and sender IDs are configurable viaconfig/laravel-sms.php. -
Error Handling
Exceptions thrown on missing credentials or failed response.
-
Composer Installable
Package can be installed via Composer and integrated seamlessly with Laravel.
Installation
Require the package via Composer:
composer require sujonmia/laravel-sms
Configuration
1. Register Service Provider & Facade Alias
Open config/app.php and add the provider & alias:
'providers' => [ // Other Service Providers... SujonMia\Smsbd\SMSServiceProvider::class, ], 'aliases' => [ // Other Facades... 'SMS' => \SujonMia\Smsbd\Facades\SMS::class, ],
2. Publish Config & Migration
php artisan vendor:publish --provider="SujonMia\Smsbd\SMSServiceProvider" php artisan migrate
3. Add Single Provider or All Provider Environment Variables
# Default provider SMS_GATEWAY=arena # Arena SMS ARENA_API_KEY=your_api_key ARENA_ACODE=your_acode ARENA_SENDER_ID=MYSHOP ARENA_URL=https://sms.lpeek.com/API/sendSMS # Elitbuzz ELITBUZZ_API_KEY=your_api_key ELITBUZZ_TYPE=text ELITBUZZ_SENDER_ID=MYSHOP ELITBUZZ_URL=https://msg.elitbuzz-bd.com/smsapi # BulkSMSBD BULKSMSBD_API_KEY=your_api_key BULKSMSBD_SENDER_ID=MYSHOP BULKSMSBD_URL=http://bulksmsbd.net/api/smsapi # Twilio TWILIO_SID=your_sid TWILIO_TOKEN=your_token TWILIO_SENDER_ID=+123456789
4. Example Usage in Controller
namespace App\Http\Controllers; use Illuminate\Http\Request; use SujonMia\Smsbd\Facades\SMS; class SmsController extends Controller { public function send() { // Send with default sender (from config) SMS::send('017XXXXXXXX', 'Hello from default sender!'); // Send with custom sender SMS::sender('SUJON')->send('017XXXXXXXX', 'Hello from custom sender!'); // Explicit provider SMS::via('arena')->send('8801743776488','Hello via Arena'); // Another provider SMS::via('bulksmsbd')->send('01743776488','Hello via BulkSMSBD'); // Another provider with custom sender SMS::via('bulksmsbd')->sender('SUJON')->send('01743776488','Hello via from custom sender BulkSMSBD'); } }
5. Log & View History
use SujonMia\Smsbd\Models\SmsLog; $logs = SmsLog::where('status', 'sent')->latest()->get();
6. Example SMS Logs Table
| ID | To | Message | Provider | Status | Response | Created At |
|---|---|---|---|---|---|---|
| 1 | 017XXXXXXXX | Your OTP is 123456 | SujonMia\Smsbd\Gateways\TwilioGatewa | sent | {…} JSON Data | 2025-08-30 |
| 2 | 018XXXXXXXX | Promo: 50% OFF | SujonMia\Smsbd\Gateways\ArenaGatewa | failed | Error Message | 2025-08-30 |
| 3 | 016XXXXXXXX | Your appointment.. | SujonMia\Smsbd\Gateways\ElitbuzzGatewa | sent | {…} JSON Data | 2025-08-30 |
| 3 | 015XXXXXXXX | Thank you.. | SujonMia\Smsbd\Gateways\BulkSMSBDGatewa | failed | Error Message | 2025-08-30 |
License
This package is open-sourced software licensed under the MIT license.
Credits
Contributing
Contributions are welcome!
If you’d like to improve this package, please fork the repo and submit a pull request.
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-28