PHP code example of creonit / sms-bundle
1. Go to this page and download the library: Download creonit/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/ */
creonit / sms-bundle example snippets
use Creonit\SmsBundle\Message\SmsMessage;
use Creonit\SmsBundle\Mime\Phone;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class SmsController extends AbstractController
{
public function smsAction()
{
$message = new SmsMessage();
$message
->setContent('Message content')
->setTo(new Phone('77777777777'))
->addTo(new Phone('77777777778'))
->addTo('77777777778');
$this->dispatchMessage($message);
}
}
use Creonit\SmsBundle\Message\SmsMessage;
use Creonit\SmsBundle\Mime\Phone;
use Symfony\Component\Messenger\MessageBusInterface;
class SmsSender
{
protected $messageBus;
public function __construct(MessageBusInterface $messageBus)
{
$this->messageBus = $messageBus;
}
public function send()
{
$message = new SmsMessage();
$message
->setContent('Message content')
->setTo(new Phone('77777777777'))
->addTo(new Phone('77777777778'))
->addTo('77777777778');
$this->messageBus->dispatch($message);
}
}