mindertech/laravel-aliyun-dysms
Composer 安装命令:
composer require mindertech/laravel-aliyun-dysms
包简介
Aliyun SMS PHP SDK for Laravel
README 文档
README
-
add the following to your composer.json. Then run
composer update:"pgroot/laravel-aliyun-dysms": "dev-master"
or
composer require pgroot/laravel-aliyun-dysms
-
Run the command below to publish the package config file
config/dysms.php:php artisan vendor:publish --provider=Mindertech\Dysms\MindertechDysmsServiceProvider
Configuration
Set the property values in the config/dysms.php.
default
return [ 'access_key_id' => '', 'access_key_secret' => '', 'sign' => '', 'log' => false, 'sms-report-queue' => '', 'sms-up-queue' => '', //以下配置暂时无需替换 'product' => 'Dysmsapi', 'domain' => 'dysmsapi.aliyuncs.com', 'region' => 'cn-hangzhou', 'end_point_name' => 'cn-hangzhou', 'mns' => [ 'account_id' => '1943695596114318', 'product' => 'Dybaseapi', 'domain' => 'dybaseapi.aliyuncs.com', 'wait_seconds' => 3 ], ];
Usage
-
send sms
try { $bizId = SendSms::to('SMS_123456', '18688886666', [ 'code' => mt_rand(1000, 9999) ]); } catch(\Exception $e) { echo $e->getMessage(); }
-
query sms
$page = 1; $pageSize = 1; $bizId = null; $result = QuerySms::search('18688886666', '20180516', $page, $pageSize, $bizId);
response
{ "page": 1, "pageSize": 1, "sendDate": "20180516", "result": [{ "SendDate": "2018-05-16 16:04:53", "SendStatus": 3, "ReceiveDate": "2018-05-16 16:04:57", "ErrCode": "0", "TemplateCode": "SMS_123456", "Content": "", "PhoneNum": "18688886666" }], "total": 7 } -
send batch sms
try { $bizId = SendSmsBatch::to( 'SMS_123456', [ '18688886666', '18666666666' ], [ 'sign-1', 'sign-2' ], [ [ 'code' => mt_rand(1000, 9999) ], [ 'code' => mt_rand(1000, 9999) ] ] ); } catch (\Exception $e) { echo $e->getMessage(); }
-
MNS
see: https://help.aliyun.com/document_detail/55500.html
/** * 回调 * @param stdClass $message 消息数据 * @return bool 返回true,则工具类自动删除已拉取的消息。返回false,消息不删除可以下次获取 */ SmsQueue::up(function($message) { /* { "dest_code": "2199787" "send_time": "2018-05-16 18:05:13" "sign_name": "signname" "sp_id": null "sequence_id": 531571249 "phone_number": "18688886666" "content": "回复测试" } */ print_r($message); return true; });
/** * 回调 * @param stdClass $message 消息数据 * @return bool 返回true,则工具类自动删除已拉取的消息。返回false,消息不删除可以下次获取 */ SmsQueue::report(function($message) { /* { "send_time": "2018-05-16 14:18:57" "report_time": "2018-05-16 14:19:02" "success": true "err_msg": "用户接收成功" "err_code": "DELIVERED" "phone_number": "18688886666" "sms_size": "1" "biz_id": "48490846451537371^0" "out_id": null } */ print_r($message); return true; });
-
set config at runtime
try { $bizId = SendSms::setRuntimeConfig([ 'access_key_id' => 'id', 'access_key_secret' => 'key' ])->to('SMS_123456', '18688886666', [ 'code' => mt_rand(1000, 9999) ]); } catch(\Exception $e) { echo $e->getMessage(); }
Todo
mindertech/laravel-aliyun-dysms 适用场景与选型建议
mindertech/laravel-aliyun-dysms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 370 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「sdk」 「laravel」 「aliyun」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mindertech/laravel-aliyun-dysms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mindertech/laravel-aliyun-dysms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mindertech/laravel-aliyun-dysms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
Alfabank REST API integration
A fork of simplesoftwareio/simple-sms with Verimor driver.
Aakash Sms Provider Api Wrapper
统计信息
- 总下载量: 370
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-25