PHP code example of jdecool / mercure

1. Go to this page and download the library: Download jdecool/mercure library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdecool / mercure example snippets


// 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!'));