Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdecool/php-mercure
Fork of the official symfony/mercure component using `HTTPlug` client.
https://github.com/jdecool/php-mercure
Last synced: about 2 months 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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-15T20:53:25.000Z (about 4 years ago)
- Last Synced: 2024-04-19T04:22:27.173Z (9 months 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
=================================[![Build Status](https://github.com/jdecool/php-mercure/workflows/Continuous%20Integration/badge.svg)](https://github.com/jdecool/php-mercure/actions?query=workflow%3A%22Continuous+Integration%22)
[![Latest Stable Version](https://poser.pugx.org/jdecool/mercure/v/stable.png)](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!'));
```