我正在制作我的第一个 zend 应用程序,但我遇到了自动加载模块的问题。此时我加载了一个表单,该表单保存在“用户”表单的“表单”中,但出现“致命错误”。这是我的配置:
应用程序.ini:
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resouces.modules = ""
resources.frontController.params.displayExceptions = 1
;my library dir
autoLoaderNameSpaces.test = "Test_"
resources.view.helperPath.Zend_View_Helper = APPLICATION_PATH "/modules/default/views/helpers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = layout
resources.view.doctype = "HTML5"
目录树:
application
-configs
-layouts
-modules
--default
--users
---controllers
----indexController.php -> class Users_IndexController extends Zend_Controller_Action
---forms
----Login.php -> class Users_Form_Login extends Zend_Form
---models
---views
---Bootstrap.php -> class Users_Bootstrap extends Zend_Application_Module_Bootstrap{}
--Bootstrap.php -> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{}
. . .
在 Users_IndexController 的 indexAction() 中,我写道:
$form = new Users_Form_Login();
我得到这个错误:
Fatal error: Class 'Users_Form_Login' not found in [...]/application/modules/users/controllers/IndexController.php on line 39
编辑
@Tim Fountain 的补充课程内容:
引导文件:
在 Bootstrap.php 中:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initActionHelpers ()
{
$config = $this->getOptions();
$acl = new Test_Acl($config['acl']);
$aclHelper = new Test_Controller_Action_Helper_Acl(null, array('acl'=>$acl));
Zend_Controller_Action_HelperBroker::addHelper($aclHelper);
}
}
在 /Users/Bootstrap.php 中:
class Users_Bootstrap extends Zend_Application_Module_Bootstrap
{
}