eislambey / amp-mercure-publisher
Async Mercure publisher for PHP based on Amp.
v0.1.0
2019-08-12 11:27 UTC
Requires
- amphp/artax: ^3.0
- symfony/mercure: ^0.2.0
Requires (Dev)
- dg/bypass-finals: ^1.1
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2024-10-29 06:18:26 UTC
README
Async Mercure publisher based on Amphp.
Installation
composer require eislambey/amp-mercure-publisher
Usage
<?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)); });
Tests
composer test
License
The MIT License. See LICENSE