maurit / sms-bundle
Sms sending system with different providers
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 6
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4.0
- ext-intl: *
- ext-json: *
- giggsey/libphonenumber-for-php: ^8.12
- guzzlehttp/guzzle: ^7.5
- nette/utils: ^3.2
- symfony/framework-bundle: ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- symfony/console: ^6.0
This package is auto-updated.
Last update: 2024-04-30 00:39:31 UTC
README
This bundle will help you to implement a sms messages to your project
Installation
You can install this bundle by the following command:
$ composer require maurit/sms-bundle ^1.0
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]
- EuroSMS com [eurosms.com]
- SmsBrana sk [sms-brana.sk]
- Smsgate sk [smsgate.sk]
Usage
In your controller
<?php // src/Controller/FooController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Maurit\Bundle\SmsBundle\Service\ProviderManager; use Maurit\Bundle\SmsBundle\Sms\Sms; class FooController extends AbstractController { 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\AbstractController; use Maurit\Bundle\SmsBundle\Service\ProviderManager; use Maurit\Bundle\SmsBundle\Sms\Sms; class FooController extends AbstractController { 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 maurit:sms:delivery:test [your_provider_name] [your_phone_number] [your_message_text]