我是ZF2的新手,并且在应该是一个基本想法方面遇到了一些麻烦.
我正在使用ZfCommons用户模块进行身份验证,它已经安装并且运行正常.
现在我想验证用户实际上是从我的控制器基于此登录的(如何检查用户是否已登录但我无法弄清楚如何注册控制器插件,我当前收到此错误:
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for ZfcUserAuthentication
Run Code Online (Sandbox Code Playgroud)
我的控制器看起来像这样:
<?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();
} …Run Code Online (Sandbox Code Playgroud)