1

Symfony\Component\Mercure\Publisher 的自动装配有问题。相反,我被错误地自动连接 Symfony\Component\Mercure\Debug\TraceablePublisher。我该如何解决?

错误消息是: 传递给 App\Controller\PublisherController::index() 的参数 1 必须是 Symfony\Component\Mercure\Publisher 的实例,给出 Symfony\Component\Mercure\Debug\TraceablePublisher 的实例,在 C:\xampp 中调用\htdocs\freely\vendor\symfony\http-kernel\HttpKernel.php 在第 145 行

<?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');
    }
}
4

0 回答 0