我尝试在我的layout.phtml中使用身份视图帮助程序
$this->identity();但是会出现这个错误:
No AuthenticationServiceInterface instance provided in vendor\zendframework\zend-view\src\Helper\Identity.php on line 38发布于 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
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:
'service_manager' => [
'factories' => [
\Zend\Authentication\AuthenticationService::class => \Application\Service\Factory\AuthenticationServiceFactory::class,
]
],为您的AuthenticationService创建一个工厂,在该工厂中告诉服务使用哪个适配器来检查身份是否有效。请参阅https://docs.zendframework.com/zend-authentication/intro/#usage
https://stackoverflow.com/questions/53117633
复制相似问题