This package is abandoned and no longer maintained. The author suggests using the https://github.com/symfony/nexmo-notifier package instead.

Symfony Nexmo SMS integration

Installs: 194

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 0

Open Issues: 1


v0.1.0 2018-09-14 06:13 UTC

This package is not auto-updated.

Last update: 2021-07-23 23:47:49 UTC


Nexmo SMS integration for Symfony. This bundle provides a simple service to send SMS from your application.

Build Status


Use Composer to install NexmoBundle in your project:

composer require "zhb/nexmo-bundle"


First of all, create a Nexmo account. Next, configure the bundle :

# config/packages/zhb_nexmo.yaml

    provider: 'zhb_nexmo.mail' # (optional) default to zhb_nexmo.sms
    disable_delivery: true # (optional) default to false.
        api_key: 'nexmo_api_key'
        api_secret: 'nexmo_api_secret'
        from: 'John Doe'
        ttl: '86400000' # (optional) default to 259200000 ms.
        callback: 'https://website.com/zhb-nexmo/delivery-receipt' # (optional) default to null. This parameter overrides the webhook endpoint you set in Dashboard.
        from: 'email@sent.from'
        to: 'email@sent.to'

To be able to use Nexmo delivery receipt (DLR) :

# config/routes/zhb_nexmo.yaml

    resource: '@ZhbNexmoBundle/Resources/config/routes.xml'
    prefix: /zhb-nexmo/delivery-receipt # change as you want

To set up the webhook used for incoming messages, use zhb_nexmo.sms.callback parameter or use the message setter :


Alternatively, you can go to the your numbers section of the Nexmo Dashboard. Click 'edit' for the virtual number and set the Callback URL (the prefix defined above).


How to send an SMS


namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Zhb\NexmoBundle\Message\TextMessage;
use Zhb\NexmoBundle\Provider\MailProvider;
use Zhb\NexmoBundle\Provider\ProviderInterface;
use Zhb\NexmoBundle\Provider\SmsProvider;

class SmsController extends AbstractController
    private $provider;

    private $emailProvider;

    private $smsProvider;

    public function __construct(ProviderInterface $provider, MailProvider $emailProvider, SmsProvider $smsProvider)
        $this->provider = $provider; // provider defined in zhb_nexmo.yaml provider key.
        $this->emailProvider = $emailProvider;
        $this->smsProvider = $smsProvider;

     * @Route("/sms/send", name="sms_send")
    public function send()
        // phone number must be in E.164 format
        $message = new TextMessage('+41798562466', 'Sms message content');
        // message setters overrides global config defined in config/packages/zhb_nexmo.yaml
        $message->setFrom('Tom Cruise');
        $message->setTtl(900000); // in milliseconds

        $response = $this->provider->send($message);


How to listen for SMS delivery receipt (DLR)


namespace App\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Zhb\NexmoBundle\Event\DeliveryReceiptEvent;
use Zhb\NexmoBundle\Event\ZhbNexmoEvents;

class DeliveryReceiptSubscriber implements EventSubscriberInterface
    public function onSmsStatusChanged(DeliveryReceiptEvent $event)
        $deliveryReceipt = $event->getDeliveryReceipt();

    public static function getSubscribedEvents()
        return [
           ZhbNexmoEvents::SMS_STATUS_CHANGED => 'onSmsStatusChanged',