Symfony

Real-time & WebSockets

Mercure, WebSockets, Server-Sent Events, push notifications, real-time updates

18 interview questions·
Senior
1

What is Symfony's recommended protocol for implementing real-time features?

Answer

Mercure is Symfony's officially recommended protocol for real-time features. Developed by Kévin Dunglas (creator of API Platform), Mercure is based on Server-Sent Events (SSE) and offers native Symfony integration via the symfony/mercure bundle. It enables efficient server-to-client unidirectional communication with automatic reconnection.

2

What is the main difference between WebSockets and Server-Sent Events (SSE)?

Answer

WebSockets establish a bidirectional full-duplex connection allowing both client and server to send messages at any time. SSE is unidirectional: only the server can send data to the client. SSE uses standard HTTP (easier to deploy behind proxies), while WebSockets use a distinct protocol after the initial handshake.

3

Which Symfony bundle enables Mercure integration in an application?

Answer

The symfony/mercure-bundle provides official Mercure integration with Symfony. It automatically configures the HubInterface service for publishing updates and generates subscription URLs. The bundle is installed via Composer and requires an external Mercure hub (Caddy with Mercure module or standalone Mercure binary).

4

How to publish a message to a Mercure topic from a Symfony controller?

5

What is the purpose of JWT in Mercure authentication for private topics?

+15 interview questions

Master Symfony for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free