这个问题与
有关How to disable redirection after login_check in Symfony 2
我已经完全实现了在该链接上给出的解决方案,但是我收到了一个我通常理解的错误但是在这种情况下没有。我的课程完全实现了界面(我认为)。
致命错误:Foo \ AppBundle \ Handler \ AuthenticationHandler :: onAuthenticationSuccess()的声明必须与/ Users / Me / Sites /中Symfony \ Component \ Security \ Http \ Authentication \ AuthenticationSuccessHandlerInterface :: onAuthenticationSuccess()的声明兼容第6行的github / Foo / Symfony / src / Foo / AppBundle / Handler / AuthenticationHandler.php
class AuthenticationHandler implements
\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface,
\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface
{
function onAuthenticationSuccess(Request $request, TokenInterface $token) {
return new Response();
}
function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
return new Response();
}
}
建议赞赏!
答案 0 :(得分:5)
PHP认为Request
,TokenInterface
来自当前的命名空间,但接口的声明要求它们来自Symfony\*
命名空间。
尝试添加using语句或对这些类使用FQN:
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;