我的application.ini看起来像这样:
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 = ""
resourceses.includePaths.library = APPLICATION_PATH "/../../library"
resources.layout.layout = layout
admin.resources.layout.layout = admin
index.php看起来像这样
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../../library'),
APPLICATION_PATH . '/modules/admin/models',
get_include_path(),
)));
/** 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();
我的应用程序/ bootstrap.php看起来像这样:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initAutoload() {
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => dirname(__FILE__) . '/modules/admin'
));
}
}
最后我的模块Bootstrap看起来像这样:
<?php
class admin_Bootstrap extends Zend_Application_Module_Bootstrap {
}
我正在尝试开发和管理员模块。我把它设置在文件夹application / modules下。我收到这个错误:
Warning: include_once(Zend\Paginator\Adapter\Select.php) [function.include-once]: failed to open stream: No such file or directory in E:\wamp\www\industrial\library\Zend\Loader.php on line 146
Warning: include_once() [function.include]: Failed opening 'Zend\Paginator\Adapter\Select.php' for inclusion (include_path='E:\wamp\www\industrial\application/../library;;E:\wamp\www\industrial\application/modules/admin/models;E:\wamp\www\industrial\library;.;C:\php5\pear') in E:\wamp\www\industrial\library\Zend\Loader.php on line 146
Fatal error: Class 'Zend_Paginator_Adapter_Select' not found in E:\wamp\www\industrial\application\modules\admin\controllers\UsersController.php on line 11
无法理解有什么不对。 PS:我使用this教程来设置模块
答案 0 :(得分:2)
无需为模块添加包含路径。
根本不需要:
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../../library'),
APPLICATION_PATH . '/modules/admin/models',
get_include_path(),
)));
但请确保此include路径包含Zend Framework库的路径。
可能你错过了:
resources.modules[] =
application.ini
中的。
答案 1 :(得分:0)
除了takehin所说的,你不遵守命名惯例.... 类名必须始终以大写字母开头。
所以改变......
class admin_Bootstrap extends Zend_Application_Module_Bootstrap {}
到
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {}
你的方式可能适用于Windows,但在linux上它会死...
答案 2 :(得分:0)
评论此行
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"