1

Here is the error message : Argument 1 passed to App\Controller\PublisherController::index() must be an instance of Symfony\Component\Mercure\Publisher, instance of Symfony\Component\Mercure\Debug\TraceablePublisher given, called in /home/gw01/Etna/PLI/vendor/symfony/http-kernel/HttpKernel.php on line 145 (500 Internal Server Error)

PublisherController :

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mercure\Publisher;
use Symfony\Component\Mercure\Update;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class PublisherController
 * @package App\Controller
 */
class PublisherController extends AbstractController
{
    /**
     * @Route("/publish/{topic}", name="publisher", methods={"POST"})
     */
    public function index(Publisher $publisher, $topic, Request $request)
    {
        $publisher(new Update($topic, $request->getContent()));
        return new Response('success');
    }
}

How can i fix this ?

Zahreddine Laidi
  • 560
  • 1
  • 7
  • 20
  • No actual experience with mercure, but I'd say changing the typehint to `PublisherInterface` should do the trick. – msg Sep 11 '20 at 15:57

0 Answers0