huangdijia / smsease
Smsease,基于easysms
0.3.3
2020-11-24 10:16 UTC
Requires
- alibabacloud/client: ^1.5
- guzzlehttp/guzzle: ^6.0|^7.0
- overtrue/easy-sms: ^1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- hyperf/di: ^2.0
- hyperf/event: ^2.0
- hyperf/framework: ^2.0
- hyperf/guzzle: ^2.0
- hyperf/utils: ^2.0
- illuminate/console: ^5.7|^6.0|^7.0|^8.0
- illuminate/support: ^5.7|^6.0|^7.0|^8.0
- phpstan/phpstan: ^0.12.55
- phpunit/phpunit: ^8.0|^9.0
README
安装
composer require huangdijia/smsease
快速开始
PHP
- 调用
use Huangdijia\Smsease\Smsease; $config = [ // HTTP request timeout 'timeout' => 5.0, // Default send options 'default' => [ // Gateway strategy, default: OrderStrategy 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, // gateway using 'gateways' => [ 'accessyou', 'aliyun', ], ], // Available gateways 'gateways' => [ 'accessyou' => [ '__gateway__' => \Huangdijia\Smsease\Gateways\AccessyouGateway::class, // custom 'account' => 'account', 'password' => 'password', ], 'aliyun' => [ 'access_key_id' => '', 'access_key_secret' => '', 'sign_name' => '', ], //... ], ]; $smsease = new Smsease($config); $smsease->send(13188888888, [ 'content' => 'Your verify code: 1234', 'template' => 'SMS_001', 'data' => [ 'code' => 1234 ], ]);
Hyperf
- 发布
php bin/hyperf.php vendor:publish "huangdijia/smsease"
- 调用
// Make by container $container = \Hyperf\Utils\ApplicationContext::getcontainer(); $smsease = $container->get(\Huangdijia\Smsease\Smsease::class);
或
// Make by annotation class Foo { @Inject @var \Huangdijia\Smsease\Smsease::class private $smsease; // ... }
- 选项
如果您想使用协程,请将class_map设置添加到您项目的 config/autoload/annotations.php
return [ 'scan' => [ // ... 'class_map' => [ \GuzzleHttp\Client::class => BASE_PATH . '/vendor/huangdijia/smsease/class_map/GuzzleHttp/Client.php', ], ], ];
Laravel
- 发布
php artisan vendor:publish --provider="Huangdijia\Smsease\SmseaseServiceProvider"
- 调用
$smsease = app(\Huangdijia\Smsease\Smsease::class); // or $smsease = app('smsease');