SmsBundle
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 yamilovs/sms-bundle ^1.0
Configuration
You can define as many provider configurations as you want. Available providers are:
Usage
In your controller
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Yamilovs\Bundle\SmsBundle\Service\ProviderManager;
use Yamilovs\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
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Yamilovs\Bundle\SmsBundle\Service\ProviderManager;
use Yamilovs\Bundle\SmsBundle\Sms\Sms;
class FooController extends Controller
{
public function barAction(ProviderManager $providerManager)
{
$provider = $providerManager->getProvider('your_provider_name');
$worldCupStartDate = (new \DateTime("2018:06:30 00:00:00"))->setTimezone(new \DateTimeZone('Europe/London'));
$remindDate = (new \DateTime())->add(new \DateInterval('PT5M'));
$worldCupStartSms = new Sms('+12345678900', '2018 FIFA World Cup started!', $worldCupStartDate);
$remindSms = new Sms('+12345678900', 'I will remind you of football', $remindDate);
$provider->send($worldCupStartSms);
$provider->send($remindSms);
}
}