Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 895 Bytes

README.md

File metadata and controls

35 lines (25 loc) · 895 Bytes

Amphp Mercure Publisher

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