Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/symfony/mercure
The Mercure Component allows to easily push updates to web browsers and other HTTP clients using the Mercure protocol.
https://github.com/symfony/mercure
live-updates mercure php server-sent-events subscriptions symfony
Last synced: 5 days ago
JSON representation
The Mercure Component allows to easily push updates to web browsers and other HTTP clients using the Mercure protocol.
- Host: GitHub
- URL: https://github.com/symfony/mercure
- Owner: symfony
- License: mit
- Created: 2018-10-23T10:30:45.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T12:52:42.000Z (9 months ago)
- Last Synced: 2024-10-29T17:18:46.451Z (2 months ago)
- Topics: live-updates, mercure, php, server-sent-events, subscriptions, symfony
- Language: PHP
- Homepage: https://symfony.com/doc/current/components/mercure.html
- Size: 128 KB
- Stars: 414
- Watchers: 7
- Forks: 39
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Mercure Component
=================> 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](https://mercure.rocks).
Getting Started
---------------```
$ composer require symfony/mercure
``````php
// 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\Hub;
use Symfony\Component\Mercure\Jwt\StaticTokenProvider;
use Symfony\Component\Mercure\Update;$hub = new Hub(HUB_URL, new StaticTokenProvider(JWT));
// Serialize the update, and dispatch it to the hub, that will broadcast it to the clients
$id = $hub->publish(new Update('https://example.com/books/1.jsonld', 'Hi from Symfony!'));
```Resources
---------* [Documentation](https://symfony.com/doc/current/mercure.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/mercure/issues) and
[send Pull Requests](https://github.com/symfony/mercure/pulls)
in the [`symfony/mercure` repository](https://github.com/symfony/mercure)