0

我正在使我的 bootstrap.php 文件更有条理,但是在将所有内容放入单独的静态方法之后,我无法加载索引控制器之外的任何页面。例如,如果我尝试打开

http://localhost/zftutorial/login/index

我明白了

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 
'Invalid controller class ("Login_IndexController")' in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php:341 
Stack trace: #0 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php(255): 
Zend_Controller_Dispatcher_Standard->loadClass('IndexController') #1 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Front.php(934): 
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), 
Object(Zend_Controller_Response_Http)) #2 C:\Program 
Files\VertrigoServ\www\zftutorial\public\index.php(18): Zend_Controller_Front->dispatch() 
#3 C:\Program Files\VertrigoServ\www\zftutorial\public\index.php(138): Bootstrap::run() #4
 {main} thrown in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php on 
line 341

在我的引导文件中,我似乎已经定义了应该在哪里找到控制器:

public static function setupFrontController()
{
    self::$frontController = Zend_Controller_Front::getInstance();
    self::$frontController->throwExceptions(true);
    self::$frontController->returnResponse(true);
    self::$frontController->setBaseUrl('/zftutorial');

    self::$frontController->setControllerDirectory(
        array(
            'default' => self::$root . '../application/controllers',
            'admin' => self::$root . '../application/controllers',
            'index' => self::$root . '../application/controllers',
            'login' => self::$root . '../application/controllers',
            'user' => self::$root . '../application/controllers'
        )
    );

    self::$frontController->setParam('registry', self::$registry);

}

也许它与路由有关,但我的应用程序以前在隐式路由方面工作得很好,例如其他控制器也工作得很好。上述错误的根源是什么?我该如何测试/查找/修复它?

4

1 回答 1

0

查看您的堆栈跟踪错误是无效的控制器类(“Login_IndexController”)

这表明类 Login_IndexController 不存在。

您应该在登录模块的控制器目录中有一个名为 IndexController.php 的文件。您目前拥有的结构将不起作用,因为两个模块不能有同名的控制器。将结构更改为

self::$frontController->setControllerDirectory(
        array(
            'default' => self::$root . '../application/modules/default/controllers',
            'admin' => self::$root . '../application/modules/admin/controllers',
            'index' => self::$root . '../application/modules/index/controllers',
            'login' => self::$root . '../application/modules/login/controllers',
            'user' => self::$root . '../application/modules/user/controllers'
        )
    );

在 self::$root 中创建 IndexController.php。'../application/modules/login/controllers 并确保该类被称为 Login_IndexController

于 2009-04-09T12:17:11.720 回答