Skip to content

eislambey/amp-mercure-publisher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Async Mercure publisher based on Amphp.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages