2012-06-16 54 views
0

我的应用程序的结构是这样的:自动加载模式,形成内部模块Zend框架

  • 应用
    • 模块
      • 默认
      • 学生
        • 控制器
        • 形式
          • studentParent.php
        • 车型
        • 意见
        • Boostrap.php

我有一个studentParent.php内形成学生模块的文件夹。

class Student_Form_studentParent extends Zend_Dojo_Form{ 
} 

每当我把里面的学生模块控制器这种形式上课,我得到找不到类错误 我已经把bootstrap.php中的学生模块内。

class Student_Bootstrap extends Zend_Application_Module_Bootstrap 
{ 

} 

这是我的application.ini文件配置

resources.frontController.params.displayExceptions = 0 
resource.modules="" 
resources.view = "" 
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" 
resources.layout.layout = "main_template" 

我的bootstrap.php文件:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 
{ 
    protected function _initDefaultModuleAutoloader() 
    { 
     $moduleLoader = new Zend_Application_Module_Autoloader(
    array(
     "namespace" => '', 
     "basePath" => APPLICATION_PATH.'/modules/default' 
     ) 
    ); 

      Zend_Controller_Action_HelperBroker::addPrefix('App_Action_Helper'); 

      return $moduleLoader; 
    } 
} 

回答

3
resource.modules="" 

应该是:

resources.modules="" 

(即资源复数)。

我还建议您使用大写字母来启动您的类名,所以Student_Form_StudentParent而不是Student_Form_studentParent(文件名也需要为StudentParent.php)。我想,个人喜好,但如果框架以一种方式做,而你的应用程序做了另一种方式,那么你的类命名将不一致。

0

另外,

$moduleLoader = new Zend_Application_Module_Autoloader(
array(
    "namespace" => '', 
    "basePath" => APPLICATION_PATH.'/modules/default' 
    ) 
); 

基本路径应指向包含模块的目录,而不是如在你的例子中,以特定的模块目录。

+0

其实模块自动加载机应指向在模块目录,他有什么是正确的 –