2010-11-13 82 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"