首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >zendframework 3-标识视图帮助器错误

zendframework 3-标识视图帮助器错误
EN

Stack Overflow用户
提问于 2018-11-02 19:20:09
回答 1查看 232关注 0票数 1

我尝试在我的layout.phtml中使用身份视图帮助程序

代码语言:javascript
复制
$this->identity();

但是会出现这个错误:

代码语言:javascript
复制
No AuthenticationServiceInterface instance provided in  vendor\zendframework\zend-view\src\Helper\Identity.php on line 38
EN

回答 1

Stack Overflow用户

发布于 2018-11-08 17:46:21

您是否在您的services of ServiceManager中实际设置并注册了Zend-Authentication

因为IdentityHelper的工厂将设置AuthenticationService

请参阅:https://github.com/zendframework/zend-mvc-plugin-identity/blob/1.1.0/src/IdentityFactory.php#L27-L31

代码语言:javascript
复制
    if ($container->has(AuthenticationService::class)) {
        $plugin->setAuthenticationService($container->get(AuthenticationService::class));
    } elseif ($container->has(AuthenticationServiceInterface::class)) {
        $plugin->setAuthenticationService($container->get(AuthenticationServiceInterface::class));
    }

在应用程序module.config.php中注册AuthenticationService:

代码语言:javascript
复制
'service_manager' => [
    'factories' => [
        \Zend\Authentication\AuthenticationService::class => \Application\Service\Factory\AuthenticationServiceFactory::class,
    ]
],

为您的AuthenticationService创建一个工厂,在该工厂中告诉服务使用哪个适配器来检查身份是否有效。请参阅https://docs.zendframework.com/zend-authentication/intro/#usage

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53117633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档