symfony / mercure
Symfony Mercure Component
Fund package maintenance!
fabpot
Tidelift
symfony.com/sponsor
Installs: 1 024 358
Dependents: 10
Suggesters: 0
Security: 0
Stars: 254
Watchers: 7
Forks: 18
Open Issues: 0
Requires
- php: >=7.1.3
- symfony/http-client: ^4.3.5|^5.0
Requires (Dev)
- symfony/phpunit-bridge: ^4.2.4|^5.0
- symfony/stopwatch: ^4.3|^5.0
Suggests
- symfony/stopwatch: Integration with the profiler performances
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
// change these values accordingly to your hub installation define('HUB_URL', 'https://demo.mercure.rocks/.well-known/mercure'); define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM'); use Symfony\Component\Mercure\Jwt\StaticJwtProvider; use Symfony\Component\Mercure\Publisher; use Symfony\Component\Mercure\Update; $publisher = new Publisher(HUB_URL, new StaticJwtProvider(JWT)); // Serialize the update, and dispatch it to the hub, that will broadcast it to the clients $id = $publisher(new Update('https://example.com/books/1.jsonld', 'Hi from Symfony!'));