未加载Zend模块的引导程序


Bootstrap of Zend Module is not loading

我是zend的新手,所以在过去的两天里我遇到了这个问题。我找了很多,但仍然找不到任何解决方案。

可能重复的Zend模块引导程序没有加载,但它仍然不能解决我的问题。

在我的用户模块中,一切都运行得很好,这意味着除了Bootstrap之外,模型是dbtables控制器。

我只想将与用户相关的路由添加到用户模块引导程序中。我也可以将它们添加到应用程序引导程序中,但我不想使其成为一个大文件。

我的应用程序/模块/User/Bootstrap.php 中有这个

class User_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initRouter() {
        //does not work i think it should work
        echo 'joo';
        exit;
    }
}

据我所知,每次运行应用程序时,所有模块的bootsrap都会运行,但在我的情况下,它似乎不起作用。

更新:

在我的应用程序/configs/application.ini中:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = "" 
resources.db.adapter = "Mysqli"
resources.db.params.host = "xxxxx"
resources.db.params.username = "xxxxx"
resources.db.params.password = "xxxxx"
resources.db.params.dbname = "xxxxx"
resources.frontController.actionHelperPaths.Idispatch_Controller_Action_Helper = "Idispatch/Controller/Action/Helper/"
[staging : production]
[testing : production]
resources.cachemanager.database.frontend.options.caching = false
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

我的应用程序目录中的引导程序:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
    protected function _initAutoloaders() {
        //user module loader
        new Zend_Application_Module_Autoloader(array(
            'namespace' => 'User', 'basePath' => APPLICATION_PATH . '/modules/User'
        ));
    }
}

注意:我使用ZFW 1

我来这里是希望有人能在这里帮助我。如果我做错了什么,请纠正我。我将不胜感激。

谢谢。

我在ZF1的基本设置中进行了一些测试,唯一不起作用的方法是当文件名不是Bootstrap.php时。就Linux而言,它也区分大小写。

正如您正确提到的,每次都会查看模块路径,exit()在我的情况下起作用。除了文件不存在,或者配置中有拼写错误,你说你已经修复了。

此外,你不应该在你的主引导程序中需要Autoloader,但我检查了一下,它不会导致这个问题。