doudi2005 2018-04-20 12:19
浏览 60

Symfony 4,无法实例化抽象类App \ Security \ FormLoginAuthenticator。 守护

I am following this tutorial about authentication

I have a custom security class called FormLoginAuthenticator.php

use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
use Symfony\Component\Security\Core\Security;

abstract class FormLoginAuthenticator extends AbstractFormLoginAuthenticator
{
protected $router;
protected $enconder;
public function __construct(RouterInterface $router, UserPasswordEncoderInterface $encoder)
{
    $this->router = $router;
    $this->encoder = $encoder;
}
}

which extends the AbstractFormLoginAuthenticator from the symfony guard component which itself is a abstract class. However I keep gettting

Cannot instantiate abstract class App\Security\FormLoginAuthenticator

I have read about extending abstract classes and if my custom class has more than 1 abstract method I should use prefix the class keyword with `abstract. However I get that error when I added the abstract keyword. How to get around this problem

  • 写回答

3条回答 默认 最新

  • doushen1026 2018-04-20 12:30
    关注

    You don't have abstract method in your

    FormLoginAuthenticator

    , so this class shouldn't be abstract. The only abstract method is from its parent, but when you extend abstract parent, you don't define your new class as Abstract, unless there is next child, which is extending it. You can't instantiate abstract classes, thats where your error comes from. You have to define your class as normal or final Small example here - https://3v4l.org/4MQpU#v560

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器