我正在努力熟悉zend框架。我已经按照教程创建了一个新模块。由于某种原因,它找不到我的控制器。我已在application.config.php。
中注册了该模块有没有办法调试module.config.php文件?
Zend \ Mvc \ Controller \ ControllerManager :: createFromInvokable:检索失败" controlpanelcontrollercontrol(别名:Controlpanel \ Controller \ Control)"通过invokable class" Controlpanel \ Controller \ ControlController&#34 ;;类不存在
这是我的控制器
namespace Controlpanel\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class ControlController extends AbstractActionController
{
protected $albumTable;
public function indexAction()
{
return new ViewModel();
}
public function addAction()
{
}
public function editAction()
{
}
public function deleteAction()
{
}
public function getAlbumTable()
{
if (!$this->controlTable) {
$sm = $this->getServiceLocator();
$this->controlTable = $sm->get('Controlpanel\Model\ControlTable');
}
return $this->controlTable;
}
}
这是我的module.php
<?php
namespace Controlpanel;
use Controlpanel\Controller;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface,
ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
我的module.config.php
<?php
//Filename: /module/Controlpanel/config/module.config.php
return array(
'controllers' => array(
'invokables' => array(
'Controlpanel\Controller\Control' => 'Controlpanel\Controller\ControlController',
),
),
//open config for route manager
'router' => array(
//Open configuration for all possible routes
'routes' => array(
//route called controlpanel
'controlpanel' => array(
//define Zend\Mvc\Router/Http/Literal
'type' => 'Literal',
//configure the route itself
'options' => array(
//listen to /control as uri
'route' => '/control',
//define default controller and action
'defaults' => array(
'__NAMESPACE__' => 'Controlpanel\Controller',
'controller' => 'Control',
'action' => 'index',
),
),
/*'may_terminate' => true,
'child_routes' => array(
'route' => '[/controller[/action][/:id]]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'id' => '0'
),
) */
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'controlpanel' => __DIR__ . '/../view',
),
),
);