我正在尝试加载一个监听器,但 symfony 不断抛出这个错误:
ClassNotFoundException in appDevDebugProjectContainer.php line 1783:
Attempted to load class "CommandeListener" from namespace "Louvre\ReversationBundle\Services\Listeners".
Did you forget a "use" statement for another namespace?
我的课写得很好(我猜):
<?php
namespace Louvre\ReservationBundle\Services\Listeners;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
class CommandeListener {
public function checkCommand(FilterResponseEvent $event){
if (!$event->isMasterRequest() && $event->getRequest()->get('_route') == "louvre_reservation_step1") {
return;
}
$url = $this->router->generate("louvre_reservation_step1");
$response = new RedirectResponse($url);
$event->setResponse($response);
}
}
它的路径是
src/Louvre/ReservationBundle/Services/Listeners/CommandeListener.php
这是yaml服务
louvre_reservation.commande.listener:
class: Louvre\ReversationBundle\Services\Listeners\CommandeListener
tags:
- { name: kernel.event_listener, event: kernel.request, method: checkCommande }
我还有其他完美运行的服务。它们的声明方式相同。
我用谷歌搜索了这个问题,但找不到答案。
有没有人已经面临这个问题?提前致谢