1

我正在尝试熟悉 zend 框架。我已经按照教程创建了一个新模块。由于某种原因,它找不到我的控制器。我已经在 application.config.php 中注册了该模块。

有没有办法调试 module.config.php 文件?

Zend\Mvc\Controller\ControllerManager::createFromInvokable:通过可调用类“Controlpanel\Controller\ControlController”检索“controlpanelcontrollercontrol(别名:Controlpanel\Controller\Control)”失败;类不存在

这是我的控制器

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',
    ),
),


);
4

0 回答 0