Member-only story

Real-Time Private Chat in Symfony 7 with Mercure

plus MakerBundle, Doctrine, SQLite, Twig, JWT and Docker

Tihomir Manushev
18 min readMar 16, 2025
Generated with DALL-E

Introduction

Real-time private chats are a staple of modern apps like WhatsApp or Slack. With Symfony 7 and Mercure, a real-time protocol, you can create your own secure chat system.

In this article, we will build a private chat app where messages are sent only to specific users. We will set up Symfony 7, integrate Mercure with dynamic topics, secure it with JWTs, and use Twig for the frontend.

Step 1: Setting Up a New Symfony 7 Project

First, we need to create a new Symfony 7 project. The easiest way is to use the Symfony CLI, a great tool for managing Symfony applications.

If you don’t have it installed, download it from the official Symfony website.

Open your terminal and run this command to create a new project:

symfony new 32-real-time-private-chat

This command will create a new bare minimum Symfony app.

You can test if the app was created successfully by starting the built-in server. Navigate to the 32-real-time-private-chat directory in the terminal and run this command:

--

--

Tihomir Manushev
Tihomir Manushev

Written by Tihomir Manushev

Senior Backend Developer at Generic Soft

No responses yet