我似乎遇到了一个问题,即使用 Zend_Config 对象加载 Zend_Application 对象与使用文件名加载 Zend_Application 对象产生不同的结果。为了说明我的观点,我有以下两种加载方法,第一种有效(请注意,此时也定义了所有常量:
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
这个不起作用并给我错误:
致命错误:在 /var/www/RoommateExpenseBuddy/allan/library/Zend/Application/Bootstrap/Bootstrap.php:91 中未捕获的异常“Zend_Application_Bootstrap_Exception”和消息“没有向前端控制器注册的默认控制器目录”
堆栈跟踪:#0 /var/www/RoommateExpenseBuddy/allan/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#1 /var/www/RoommateExpenseBuddy/allan/public/index.php(36): Zend_Application->run()
#2 {main} 在第 91 行抛出 /var/www/RoommateExpenseBuddy/allan/library/Zend/Application/Bootstrap/Bootstrap.php
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Config.php';
require_once 'Zend/Config/Ini.php';
require_once 'Zend/Debug.php';
$appConfig = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini', APPLICATION_ENV);
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
$appConfig
);
$application->bootstrap()
->run();
他们都使用相同的文件,如下所示:
[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"
emailNotice.email = "info@associateinnovations.com"
emailNotice.name = "Roommate Expense Buddy"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.defaultmodule = "global"
resources.frontController.params.prefixDefaultModule = true
resources.db.adapter = "PDO_MYSQL"
resources.db.isdefaulttableadapter = true
resources.db.params.dbname = "db_name"
resources.db.params.username = "db_user"
resources.db.params.password = "mypassword"
resources.db.params.hostname = "localhost"
resources.db.params.charset = "UTF8"
invitation.defaultViewPath = APPLICATION_PATH "/modules/global/views/scripts/invitation"
[staging : production]
[testing : production]
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
我的目录结构看起来像这样,重要的文件夹展开了。
|~application/
| |~configs/
| | |-application.ini
| | `-navigation.xml
| |+helpers/
| |+layouts/
| |+migrations/
| |~modules/
| | `~global/
| | |+controllers/
| | |+forms/
| | |+models/
| | `+views/
| `-Bootstrap.php
|+bin/
|+data/
|+docs/
|+library/
|+public/
`+tests/
所以重申一下,使用 Zend_Application 的构造函数中的文件名加载 INI 文件会产生预期的结果(工作应用程序)。将 Config 对象传递给 Zend_Application 的构造函数会给我上述错误。
关于为什么这会有所作为的任何线索?