m-rubin-itmegastar-com/sms-bundle
Composer 安装命令:
composer require m-rubin-itmegastar-com/sms-bundle
包简介
Sms sending system with different providers
README 文档
README
This bundle will help you to implement an sms messages to your project
Installation
You can install this bundle by the following command:
$ composer require itmegastar/sms-bundle ^1.2
Configuration
You can define as many provider configurations as you want. Available providers are:
- Message Bird [messagebird.com]
- Sms Ru [sms.ru]
- Sms Aero [smsaero.ru]
- Sms Discount [iqsms.ru]
- Sms Center [smsc.ru]
Usage
In your controller
<?php // src/Controller/FooController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use ITMegastar\Bundle\SmsBundle\Service\ProviderManager; use ITMegastar\Bundle\SmsBundle\Sms\Sms; class FooController extends Controller { public function barAction(ProviderManager $providerManager) { $sms = new Sms('+12345678900', 'The cake is a lie'); $provider = $providerManager->getProvider('your_provider_name'); $provider->send($sms); } }
If you want to schedule an sms delivery
<?php // src/Controller/FooController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use ITMegastar\Bundle\SmsBundle\Service\ProviderManager; use ITMegastar\Bundle\SmsBundle\Sms\Sms; class FooController extends Controller { public function barAction(ProviderManager $providerManager) { // Your selected sms provider $provider = $providerManager->getProvider('your_provider_name'); // Date of sms delivery $worldCupStartDate = (new \DateTime("2018:06:30 00:00:00"))->setTimezone(new \DateTimeZone('Europe/London')); $remindDate = (new \DateTime())->add(new \DateInterval('PT5M')); // Create new delayed sms $worldCupStartSms = new Sms('+12345678900', '2018 FIFA World Cup started!', $worldCupStartDate); $remindSms = new Sms('+12345678900', 'I will remind you of football', $remindDate); // Send delayed delivery to provider $provider->send($worldCupStartSms); // will be sent at 2018:06:30 00:00:00 $provider->send($remindSms); // will be sent after 5 minutes } }
Tips
You can check sms delivery by the following command:
$ php bin/console itmegastar:sms:delivery:test [your_provider_name] [your_phone_number] [your_message_text]
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-01