Async Mercure publisher based on Amphp.
composer require eislambey/amp-mercure-publisher
<?php
use Amp\Loop;
use Islambey\Amp\Mercure\Publisher;
use Symfony\Component\Mercure\Jwt\StaticJwtProvider;
use Symfony\Component\Mercure\Update;
require __DIR__ . '/vendor/autoload.php';
define('HUB_URL', 'https://demo.mercure.rocks/.well-known/mercure');
define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdfX0.obDjwCgqtPuIvwBlTxUEmibbBf0zypKCNzNKP7Op2UM');
Loop::run(function () {
$jwtProvider = new StaticJwtProvider(JWT);
$publisher = new Publisher(HUB_URL, $jwtProvider);
$update = new Update('https://example.com/books/1.jsonld', 'Hi from Amp!');
var_dump(yield $publisher->publish($update));
});
composer test
The MIT License. See LICENSE