https://github.com/jdecool/php-mercure
Fork of the official symfony/mercure component using `HTTPlug` client.
https://github.com/jdecool/php-mercure
Last synced: over 1 year ago
JSON representation
Fork of the official symfony/mercure component using `HTTPlug` client.
- Host: GitHub
- URL: https://github.com/jdecool/php-mercure
- Owner: jdecool
- License: mit
- Created: 2020-06-02T21:12:35.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-15T20:53:25.000Z (over 5 years ago)
- Last Synced: 2025-03-05T22:30:42.578Z (over 1 year ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Mercure PHP component for HTTPlug
=================================
[](https://github.com/jdecool/php-mercure/actions?query=workflow%3A%22Continuous+Integration%22)
[](https://packagist.org/packages/jdecool/mercure)
This is a fork of the official [`symfony/mercure`](https://github.com/symfony/mercure) component using `HTTPlug` client.
Thanks to [Kévin Dunglas](https://github.com/dunglas/) for his incredible work on [Mercure.rocks](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](https://mercure.rocks).
## Install it
Install using [composer](https://getcomposer.org), you need to install a [PSR-18](https://www.php-fig.org/psr/psr-18/) compliant HTTP client.
Example using Guzzle:
```bash
composer require jdecool/mercure guzzlehttp/guzzle http-interop/http-factory-guzzle
```
## Getting started
```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 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!'));
```