PHP code example of bigoen / mercure-twig-bundle

1. Go to this page and download the library: Download bigoen/mercure-twig-bundle 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/ */

    

bigoen / mercure-twig-bundle example snippets


return [
    // ...
    Bigoen\MercureTwigBundle\BigoenMercureTwigBundle::class => ['all' => true],
];

use Symfony\Component\Mercure\PublisherInterface;
use Symfony\Component\Mercure\Update;

/** @var PublisherInterface $publisher */
$publisher(new Update('live', 'test'));



declare(strict_types=1);

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/mercure", name="mercure.")
 */
class MercureController extends AbstractController
{
    /**
     * @Route("/order", name="order")
     */
    public function orderAction(): Response
    {
        return $this->render('mercure/order.html.twig');
    }
}