siganushka / aliyun-notifier
This package is abandoned and no longer maintained.
No replacement package was suggested.
Symfony Aliyun Notifier Bridge.
dev-main
2022-02-25 02:18 UTC
Requires
- php: ^7.2.5
- symfony/http-client: ^4.3|^5.0
- symfony/notifier: ^5.0
This package is auto-updated.
Last update: 2022-02-25 02:18:26 UTC
README
适用于 symfony/notifier 消息组件的 阿里云 短信传输。
该项目已废弃。
安装
$ composer require siganushka/aliyun-notifier:dev-master
配置
# .env ALIYUN_DSN=aliyun://default?access_id={ACCESS_ID}&access_secret={ACCESS_SECRET}&sign_name={SIGN_NAME}
# ./config/packages/notifier.yaml framework: notifier: texter_transports: aliyun: '%env(ALIYUN_DSN)%'
# ./config/services.yaml Siganushka\Notifier\Bridge\Aliyun\AliyunTransportFactory: tags: [ texter.transport_factory ]
发送短信
namespace App\Controller; use Siganushka\Notifier\Bridge\Aliyun\AliyunSmsMessage; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\TexterInterface; class FooController { /** * @Route("/foo") */ public function foo(TexterInterface $texter) { $templateCode = 'SMS_164611111'; $templateParam = [ 'code' => mt_rand(1000, 9999), ]; $message = new AliyunSmsMessage('18611111111', $templateCode, $templateParam); try { $texter->send($message); } catch (TransportException $th) { // 发送失败 } // ... } }