Zend framework zend框架中模块内部的自动加载模型和表单
我的应用程序结构如下:Zend framework zend框架中模块内部的自动加载模型和表单,zend-framework,zend-autoloader,Zend Framework,Zend Autoloader,我的应用程序结构如下: 应用 模块 违约 学生 控制器 形式 studentParent.php 模型 观点 Boostrap.php 我在学生模块的表单文件夹中有一个studentParent.php class Student_Form_studentParent extends Zend_Dojo_Form{ } class Student_Bootstrap extends Zend_Application_Module_Bootstrap { } 每当我在学生
- 应用
- 模块
- 违约
- 学生
- 控制器
- 形式
- studentParent.php
- 模型
- 观点
- Boostrap.php
- 模块
class Student_Form_studentParent extends Zend_Dojo_Form{
}
class Student_Bootstrap extends Zend_Application_Module_Bootstrap
{
}
每当我在学生模块的控制器内调用这个表单类时,我都会得到“未找到类”错误
我已将Bootstrap.php放在学生模块中
class Student_Form_studentParent extends Zend_Dojo_Form{
}
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"
My 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;
}
}
应该是:
resources.modules=""
(即资源的复数形式)
我还建议您使用大写字母开始您的类名,因此Student\u Form\u StudentParent
而不是Student\u Form\u StudentParent
(文件名也需要是StudentParent.php
)。我想是个人偏好,但如果框架采用一种方式,而你的应用程序采用另一种方式,那么你的类命名将不一致
应该是:
resources.modules=""
(即资源的复数形式)
我还建议您使用大写字母开始您的类名,因此Student\u Form\u StudentParent
而不是Student\u Form\u StudentParent
(文件名也需要是StudentParent.php
)。我想是个人偏好,但如果框架采用一种方式,而应用程序采用另一种方式,那么您的类命名将不一致
$moduleLoader = new Zend_Application_Module_Autoloader(
array(
"namespace" => '',
"basePath" => APPLICATION_PATH.'/modules/default'
)
);
基本路径应该指向包含模块的目录,而不是像您的示例中那样指向特定的模块目录。同样
$moduleLoader = new Zend_Application_Module_Autoloader(
array(
"namespace" => '',
"basePath" => APPLICATION_PATH.'/modules/default'
)
);
基本路径应该指向包含模块的目录,而不是像您的示例中那样指向特定的模块目录。实际上,模块自动加载程序应该指向模块目录,他拥有的是正确的。实际上,模块自动加载程序应该指向模块目录,他拥有的是正确的