symfony/mercure
Symfony Mercure Component
Maintainers
v0.7.2
2025-12-15 15:22 UTC
Requires
- php: >=8.1
- symfony/deprecation-contracts: ^2.0|^3.0
- symfony/http-client: ^6.4|^7.3|^8.0
- symfony/http-foundation: ^6.4|^7.3|^8.0
- symfony/web-link: ^6.4|^7.3|^8.0
Requires (Dev)
- lcobucci/jwt: ^3.4|^4.0|^5.0
- symfony/event-dispatcher: ^6.4|^7.3|^8.0
- symfony/http-kernel: ^6.4|^7.3|^8.0
- symfony/phpunit-bridge: ^7.3.4|^8.0
- symfony/stopwatch: ^6.4|^7.3|^8.0
- twig/twig: ^2.0|^3.0|^4.0
Suggests
- symfony/stopwatch: Integration with the profiler performances
Provides
None
Conflicts
None
Replaces
None
MIT 3ba1d19c9792d6bf66cf6cb4412ea289e9a42565
- KΓ©vin Dunglas <dunglas.woop@gmail.com>
- Symfony Community
This package is auto-updated.
Last update: 2026-06-15 16:21:59 UTC
README
Mercure is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast, reliable and battery-efficient way. It is especially useful to publish real-time updates of resources served through web APIs, to reactive web and mobile apps.
The Mercure Component implements the "publisher" part of the Mercure Protocol.
Getting Started
$ composer require symfony/mercure lcobucci/jwt
// change these values accordingly to your hub installation const HUB_URL = 'https://demo.mercure.rocks/.well-known/mercure'; const JWT_SECRET = '!ChangeThisMercureHubJWTSecretKey!'; // Set up the JWT token provider // Alternatively, you can use the \Symfony\Component\Mercure\Jwt\StaticTokenProvider if you already have a JWT token $jwFactory = new \Symfony\Component\Mercure\Jwt\LcobucciFactory(JWT_SECRET); $provider = new \Symfony\Component\Mercure\Jwt\FactoryTokenProvider($jwFactory, publish: ['*']); $hub = new \Symfony\Component\Mercure\Hub(HUB_URL, $provider); // Serialize the update, and dispatch it to the hub, that will broadcast it to the clients $id = $hub->publish(new \Symfony\Component\Mercure\Update('https://example.com/books/1.jsonld', 'Hi from Symfony!'));
