oh86 / laravel-sms
sms for laravel
v1.0.0
2025-06-13 09:15 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- laravel/framework: ^7.0||^8.0||^9.0||^10.0||^11.0
- tencentcloud/sms: ^3.0
README
一、安装
composer require oh86/laravel-sms
php artisan vendor:publish
# 可选
composer require tencentcloud/sms
二、配置
return [ 'default' => env('SMS_DRIVER', 'tencentCloudApp1'), 'drivers' => [ // 'tencentCloudApp1' => [ 'service' => 'tencentCloud', // 腾讯云短信服务 // 云平台配置 'platform' => [ 'secretId' => env('TENCENT_CLOUD_SECRET_ID'), 'secretKey' => env('TENCENT_CLOUD_SECRET_KEY'), 'region' => env('TENCENT_CLOUD_REGION', 'ap-guangzhou'), ], // 应用配置 'app' => [ 'appId' => env('TENCENT_CLOUD_SMS_APP_ID'), 'sign' => env('TENCENT_CLOUD_SMS_SIGN'), 'templateId' => env('TENCENT_CLOUD_SMS_TEMPLATE_ID'), ] ], ], ];
三、使用示例
SMS::send(['15014153877', '15014153878'], ['123456']); SMS::driver('tencentCloudApp1')->send(['15014153877', '15014153878'], ['123456']);
四、拓展
1.拓展service
app()->get(\Oh86\SMS\SMSManager::class)->extendService('serviceDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface { // TODO });
2.拓展driver
app()->get(\Oh86\SMS\SMSManager::class)->extend('driverDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface { // TODO });