0 forms zend-framework module zend-autoloader
我已经厌倦了Zend的自动加载器.
我正试图EditPassword从PasswordController模块结构中加载,如下所示.

的application.ini
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.frontController.baseUrl = "/"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
phpSettings.date.timezone = "Europe/London"
Run Code Online (Sandbox Code Playgroud)
bootstrap.php中:
public function init() {
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$baseUrl = $config->baseHttp;
define('BASE_URL', $baseUrl);
}
protected function _initAutoload() {
$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoLoader->registerNamespace('App_');
//
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH . 'modules/account',
'resourceTypes' => array(
'form' => array(
'path' => 'forms',
'namespace' => 'Form'))));
$autoLoader->pushAutoloader($moduleLoader);
//
return $autoLoader;
}
Run Code Online (Sandbox Code Playgroud)
我正在控制器中加载表单,如下所示:
$form = new Account_Form_EditPassword();
$this->view->form = $form;
Run Code Online (Sandbox Code Playgroud)
错误本身是:
Fatal error: Class 'Account_Form_EditPassword' not found in
Z:\dat\docs\workspace\metamusic\application\modules\account\controllers\PasswordController.php
on line 7
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?Zend中的其他所有内容似乎都运行了相当理智的默认值 - 我是否真的必须为每个模块声明表单/模型/视图的所有路径,因为它们遵循默认的Zend结构,并且在默认的模块目录中?
我将从应用程序Bootstrap中删除所有模块自动加载代码,然后在以下位置实现一个空模块引导程序application/modules/account/Bootstrap.php:
class Account_Bootstrap extends Zend_Application_Module_Bootstrap
{
}
Run Code Online (Sandbox Code Playgroud)
然后application/configs/application.ini,添加以下内容:
resources.modules[] =
Run Code Online (Sandbox Code Playgroud)
这里的想法是Zend_Application_Module_Bootstrap自动注册一个资源自动加载器,其中包含一组公共路径/命名空间映射,包括您正在使用的表单映射.
| 归档时间: |
|
| 查看次数: |
4159 次 |
| 最近记录: |