PHP code example of maurit / sms-bundle

1. Go to this page and download the library: Download maurit/sms-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maurit / sms-bundle example snippets



// 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);
    }
}


// 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
    }
}