jdecool / mercure
Fork of the official symfony/mercure component using HTTPlug client.
Requires
- php: >=7.3
- php-http/client-common: ^2.3
- php-http/discovery: ^1.7
- php-http/httplug: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- guzzlehttp/guzzle: ^7.0
- http-interop/http-factory-guzzle: ^1.0
- php-http/mock-client: ^1.3
- phpunit/phpunit: ^9.1
This package is auto-updated.
Last update: 2024-12-16 06:49:15 UTC
README
This is a fork of the official symfony/mercure
component using HTTPlug
client.
Thanks to Kévin Dunglas for his incredible work on Mercure.rocks. Thanks to all Symfony & Mercure contributors.
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.
This component implements the "publisher" part of the Mercure Protocol.
Install it
Install using composer, you need to install a PSR-18 compliant HTTP client.
Example using Guzzle:
composer require jdecool/mercure guzzlehttp/guzzle http-interop/http-factory-guzzle
Getting started
// 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 JDecool\Mercure\Jwt\StaticJwtProvider; use JDecool\Mercure\PublisherFactory; use JDecool\Mercure\Update; $factory = new PublisherFactory(); $publisher = $factory->create(HUB_URL, new StaticJwtProvider(JWT)); $response = $publisher(new Update('https://example.com/books/1.jsonld', 'Hi from Symfony!'));