Skip to content

Symfony Notifier: Send Your First Notification and Fix Silent Failures

AINewss Editorial Team

A practical Symfony Notifier guide for the moment notifications refuse to send. It covers installation and DSN configuration, sending via ChatterInterface, the Messenger consumer trap, failover and round-robin transports, email setup, dev-mode NullTransport and the Symfony 8.2 changes that deprecate Firebase and LINE Notify DSNs.

View 2 references
0 views 0 likes

Allow the functional cookie to save your likes. Privacy details

A terminal window showing a notification being dispatched through connected chat and email channels, representing the Symfony Notifier component.

What is the Symfony Notifier component?

The Symfony Notifier component is an abstraction over delivery channels such as SMS, chat, email, browser flash messages, push and desktop notifications. Each channel connects to providers through transports configured with DSNs. It lets application code send one notification API call while swapping providers through configuration.

The official documentation groups the channels as SMS (Texter classes), chat (Chatter classes), email (Symfony Mailer), browser (flash messages), push and desktop. A separate component page lists version 8.1.5, an MIT licence and roughly 50 million total downloads at the time checked, which indicates the component is widely used.

The abstraction is the point: your controller can call $chatter->send(...) while an operations team changes the underlying provider from Slack to Teams in configuration.

How do you install Symfony Notifier and configure a transport?

Install it with composer require symfony/notifier. Then define a DSN in .env and map it under framework.notifier in config/packages/notifier.yaml. Chat providers use chatter_transports; SMS, push and desktop providers use texter_transports. The first transport configured becomes the default when you do not pass ->transport().

A minimal Slack setup looks like this:

# .env
SLACK_DSN=slack://TOKEN@default?channel=CHANNEL
# config/packages/notifier.yaml
framework:
    notifier:
        chatter_transports:
            slack: '%env(SLACK_DSN)%'

For SMS, push or desktop, use texter_transports instead. The docs give twilio://SID:TOKEN@default?from=FROM, expo://TOKEN@default and jolinotif://default as examples. Note that many providers require an additional bridge package, such as symfony/slack-notifier.

Why are my Symfony Notifier messages never sent?

The most common cause is Messenger. The official docs warn that if Messenger is installed, notifications go through the MessageBus and will never send without a running consumer. Add framework.notifier.message_bus: false to send directly through the transport. Also check DSN characters are URL-encoded.

# config/packages/notifier.yaml
framework:
    notifier:
        message_bus: false

Two other traps are worth checking in order. First, any URI-special character in a DSN value (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) must be percent-encoded, or the transport will fail to parse it. Second, if a channel fails and you have a failure transport configured, only that channel is retried; other channels are not re-sent. The docs call the MessageBus setup the recommended one for multi-channel notifications, so fix the consumer before disabling it.

How do you send a chat notification with ChatterInterface?

Inject ChatterInterface into a controller or service, build a ChatMessage and call send(). Use ->transport('slack') to target a provider; omit it and the first configured transport is used. send() returns a SentMessage with the message ID and original content, so you can log or audit delivery.

// src/Controller/CheckoutController.php
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Message\ChatMessage;

class CheckoutController extends AbstractController
{
    #[Route('/checkout/thankyou')]
    public function thankyou(ChatterInterface $chatter): Response
    {
        $message = (new ChatMessage('You got a new invoice for 15 EUR.'))
            ->transport('slack');

        $sentMessage = $chatter->send($message);
        // $sentMessage->getMessageId(), $sentMessage->getOriginalMessage()
    }
}

Keep the transport explicit in production. Relying on "the first one configured" makes behaviour change when someone reorders configuration.

How do you send SMS, push and desktop notifications?

These channels use the Texter classes and texter_transports. Configure DSNs such as twilio://SID:TOKEN@default?from=FROM, expo://TOKEN@default or jolinotif://default under the same key. External SMS and push services require an account; the Desktop channel (introduced in 7.2) shows notifications on the host machine. Check provider DSN formats in the docs.

The browser channel is the simplest of all: by default it adds a flash message with the key notification, requiring no provider at all. That makes it a good first end-to-end test when you want to prove the component is wired before adding credentials.

For plain HTTP endpoints, the docs introduced an ssl DSN option in Symfony 8.2. Setting ssl=false is only sensible on servers you control, because credentials and notification contents then travel unencrypted.

How do you handle email notifications in Symfony Notifier?

The email channel uses Symfony Mailer and a special NotificationEmail. Install the Twig bridge with Inky and CSS Inliner extensions before enabling it. You can set a default sender via framework.mailer.envelope.sender; a From address set on the message itself always wins, and an 8.2 change added fallback to the mailer's global From.

composer require symfony/twig-pack twig/cssinliner-extra twig/inky-extra
# config/packages/mailer.yaml
framework:
    mailer:
        dsn: '%env(MAILER_DSN)%'
        envelope:
            sender: '[email protected]'

The distinction between envelope sender and From header matters for SPF/DKIM alignment. If delivery fails silently, check the mailer transport separately from Notifier first.

How do failover and round-robin transports work?

Use || for failover and && for round-robin across DSNs. A failover chain tries the next transport only when the previous one errors. Round-robin spreads messages across transports. When Messenger is enabled, each channel dispatches independently, so a failure with a failure transport retries only that channel.

framework:
    notifier:
        chatter_transports:
            main: '%env(SLACK_DSN)% || %env(TELEGRAM_DSN)%'
            roundrobin: '%env(SLACK_DSN)% && %env(TELEGRAM_DSN)%'

Failover protects against an outage; round-robin spreads load. They solve different problems and can coexist as separate transports. Store tokens with Symfony secrets rather than plain environment values where possible, and note that some bridges support webhook status callbacks.

Which Symfony Notifier changes arrived in 8.2?

Symfony 8.2 adds several changes worth planning for. WhatsApp, Facebook Page, Instagram and Threads integrations arrived, and the Firebase bridge now needs service-account credentials for FCM v1. The old firebase:// DSN is deprecated, as is LINE Notify. The ssl DSN option was also introduced in 8.2.

Other documented 8.2 items include LineBotOptions for per-message recipients, the fallback to the mailer's global From header, visibility of notifications sent during previous requests, and AdminRecipientsProviderInterface. Older notes in the same docs record Bluesky in 7.1, LINE Bot in 7.2, Matrix in 7.3, removal of Gitter in 7.2 and the Desktop channel in 7.2.

If you are upgrading, treat deprecated bridges as a migration signal: LINE Notify and the legacy Firebase API were shut down by their providers, so no amount of configuration will restore them.

How do you disable real delivery in dev and test?

Set texter_transports and chatter_transports to null://null in a when@dev block to force Notifier onto NullTransport. That prevents test runs from sending real Slack messages or SMS. It also keeps credentials out of developer machines while leaving production DSNs untouched. This is documented as a dev/test feature.

when@dev:
    framework:
        notifier:
            texter_transports:
                twilio: 'null://null'
            chatter_transports:
                slack: 'null://null'

Apply the same pattern in when@test. It is easier to audit than mocking individual services, and it fails safely if a new transport is added later.

Frequently asked questions about Symfony Notifier

Common issues are DSN encoding, background workers and provider shutdowns. Special URI characters must be percent-encoded; otherwise the transport fails to parse. Check whether a Messenger consumer is running. Deprecated bridges such as LINE Notify reflect services that have shut down, so switch to supported integrations.

Do I need Messenger to use Notifier?

No. Messenger is optional. If it is installed, notifications are dispatched through the MessageBus and need a consumer. Without it, or with message_bus: false, notifications are sent directly through the configured transport. Choose based on whether you need queued retries.

Can I send to multiple channels at once?

Yes. Configure multiple transports and send a message per channel, or use RecipientInterface/recipients where supported by your notifier class. Remember that with Messenger each channel dispatches independently, so one failing channel does not stop the others.

Which transport should I use for local development?

null://null. It uses NullTransport, which discards messages safely. For visual checking without a provider, the browser channel's flash message is also useful.

References

  1. Creating and Sending Notifications - Symfony official docssymfony.com
  2. Notifier Component - Symfony official package pagewww.symfony.com