brayun / yii2-sms
短信使用阿里云短信
Installs: 40
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- brayun/aliyun-sms: ^1.1
This package is not auto-updated.
Last update: 2024-11-10 05:14:14 UTC
README
上海柏锐网络科技有限公司是一家技术型服务企业.可提供专业的技术外包服务,定制OA,ERP,电商系统,H5网站,天猫淘宝H5,欢迎前来咨询
安装
composer require brayun/yii2-sms
示例 Controller 添加actions
public function actions() { return [ 'smscode' => [ 'class' => SendAction::className(), 'tplCode' => 'SMS_94663333', 'signName' => '我是签名', 'params' => [ 'code' => rand(1000, 9999) ], 'beforeFunction' => function () { if (User::findOne(['mobile' => \Yii::$app->request->post('mobile')])) { return [ 'code' => 1, 'msg' => '手机号码已存在!' ]; } } ] ]; }
示例Model
public function rules() { return [ ... ['code', PhoneCodeValidator::className()], ]; }
组件使用示例 main.php components下添加
'components' => [ 'sms' => [ 'class' => 'brayun\sms\Application', 'signName' => '统一签名' ], ... ]
组件使用
Yii::$app->sms->send('13000000000','SMS_123456',['code'=>1234], '这里签名可另写');