![](/img/trans.png)
[英]ReflectionException: Class does not exist after upgrading Symfony
[英]ReflectionException in RegisterListenersPass.php line 101: Class does not exist Symfony 2
這是我的第一個問題,我在RegisterListenersPass.php第101行中遇到此錯誤ReflectionException:類Acme \\ exampleBundle \\ Handler \\ AuthenticationHandler.php不存在。 我正在使用FOSUserBundle和Symfony 2。
在Services.xml中
<service id="login_listener" class="%vixur.login_listener.class%">
<tag name="kernel.event_subscriber"/>
</service>
AuthenticationHandler.php:
<?php
namespace acme\exampleBundle\Handler;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Listener responsible to change the redirection at the end of the password resetting
*/
class AuthenticationHandler implements EventSubscriberInterface
{
private $container;
public function __construct()
{
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::SECURITY_IMPLICIT_LOGIN => 'onSecurityImplicitLogin',
);
}
public function onSecurityImplicitLogin(FormEvent $event)
{
$url = $this->router->generate('ex_homepage');
$event->setResponse(new RedirectResponse($url));
}
}
謝謝!!
您確定名稱空間正確嗎? 請務必小心,因為您必須嘗試遵循Symfony編碼標准 (PSR-0和PSR-4),並且文件夾的名稱並不嚴格。 必須是CamelCase。
您是否檢查%vixur.login_listener.class%變量的值是否正確?
我只是面對同樣的情況,最終發現PHPStorm格式正在將xml更改為這樣的內容
<parameters>
<parameter key="vixur.login_listener.class">
Vixur\LoginListener
</parameter>
</parameters>
雖然應該
<parameters>
<parameter key="vixur.login_listener.class">Vixur\LoginListener</parameter>
</parameters>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.