2010-11-13 84 views
0

我的application.ini看起来是这样的:Zend的模块不加载库

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 { 

} 

我正在尝试开发和管理员模块。我已将它设置在文件夹应用程序/模块下。我得到这个错误:

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教程来设置模块

回答

2

没有必要添加包含模块的路径。

这是没有必要的:

set_include_path(implode(PATH_SEPARATOR, array(
     realpath(APPLICATION_PATH . '/../../library'), 
     APPLICATION_PATH . '/modules/admin/models', 
     get_include_path(), 
    ))); 

但是确保这个include路径包含路径到Zend框架库。

也许你错过:

resources.modules[] = 
application.ini

0

除了说什么,你不遵守命名约定......
类名必须始终以大写字母开头。

因此改变......

class admin_Bootstrap extends Zend_Application_Module_Bootstrap {} 

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {} 

你的方式在Windows,但在Linux上会死的可能工作...

0

评论这条线

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"