【发布时间】:2023-03-19 20:42:01
【问题描述】:
我是 ZF2 的新手,在基本概念方面遇到了一些问题。
我正在使用 ZfCommons 用户模块进行身份验证,它已安装并且运行正常。
现在我想验证用户实际上是基于此从我的控制器登录的(How to check if the user is logged in 但我不知道如何注册控制器插件,我目前收到此错误:
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for ZfcUserAuthentication
我的控制器如下所示:
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController as AbstractActionController;
use Zend\View\Model\ViewModel as ViewModel;
class IndexController extends AbstractActionController
{
public function __construct()
{
$plugin = $this->plugin('ZfcUserAuthentication');
}
public function indexAction()
{
return new ViewModel();
}
public function testAction()
{
return new ViewModel();
}
}
【问题讨论】:
标签: zend-framework2