huangdijia / smsease
Smseae, base 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
Installation
composer require huangdijia/smsease
Quickly Start
PHP
- Call
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
- Publish
php bin/hyperf.php vendor:publish "huangdijia/smsease"
- Call
// Make by container $container = \Hyperf\Utils\ApplicationContext::getcontainer(); $smsease = $container->get(\Huangdijia\Smsease\Smsease::class);
or
// Make by annotation class Foo { @Inject @var \Huangdijia\Smsease\Smsease::class private $smsease; // ... }
- Options
If you want using coroutine, add class_map setting into config/autoload/annotations.php
of your project
return [ 'scan' => [ // ... 'class_map' => [ \GuzzleHttp\Client::class => BASE_PATH . '/vendor/huangdijia/smsease/class_map/GuzzleHttp/Client.php', ], ], ];
Laravel
- Publish
php artisan vendor:publish --provider="Huangdijia\Smsease\SmseaseServiceProvider"
- Call
$smsease = app(\Huangdijia\Smsease\Smsease::class); // or $smsease = app('smsease');