我已经尝试了许多不同的方法来解决这个问题,我在网上找到了但是没有用,所以请有人帮助我。
我收到此错误
致命错误:第13行的pathToProject / modules / admin / controllers / LoginController.php中找不到类'Admin_Form_Login'
我的项目是
应用
--- modules
------管理员
--------控制器
--------形式
--------模型
--------视图
------默认
--------控制器
--------形式
--------模型
--------视图
------关于我们
--------控制器
--------形式
--------模型
--------视图 等等 等
我的控制器
class Admin_LoginController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$form = new Admin_Form_Login();
$this->view->form = $form;
// action body
}
}
我的表格
class Admin_Form_Login extends Zend_Form
{
public function init()
{
/* Form Elements & Other Definitions Here ... */
$this->setAction("/admin/index/login")->setMethod("post");
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
->setOptions(array('size' => '30'));
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password')
->setOptions(array('size' => '30'));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Log in')
->setOptions(array('class' => 'submit'));
$this->addElement($username)
->addElement($password)
->addElement($submit);
}
}
MY Bootstrap.php
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initAutoload() {
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => APPLICATION_PATH."/modules/admin",
));
return $autoloader;
}
}
这是我的App ini可能在那里
[bootstrap]
Autoloadernamespaces[] = "Admin_"
Autoloadernamespaces[] = "Default_"
Autoloadernamespaces[] = "Aboutus_"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultModule = "default"
resources.modules[] = ""
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = "1"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
admin.resources.layout.layout = layout
admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
default.resources.layout.layout = default
default.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
和我的观点
$this->form
感谢您的帮助。
我在生产部分ok我的application.ini中添加了以下内容并开始工作不确定原因。
Autoloadernamespaces[] = "Admin_"
Autoloadernamespaces[] = "Default_"
Autoloadernamespaces[] = "Aboutme_"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultModule = "default"
resources.modules[] = ""
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
答案 0 :(得分:0)
听Dave,清空你的Admin_Bootstrap类。如果您需要任何_init方法,请将它们放在应用程序级引导程序中。无论如何,所有引导类都在每个请求上运行,因此在应用程序级别放置任何_init方法以防止意外覆盖。
确保模块引导程序位于application/modules/admin/Bootstrap.php
(每个模块都需要引导程序),以确保资源自动加载程序正常工作。表单是自动加载器中的predefined resource,因此不需要_init方法。
确保您的application.ini包含激活模块所需的最低要求:
resources.modules = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
最后不要忘记你的观点中的echo
:
$this->form
应该是:
echo $this->form
祝你好运!
答案 1 :(得分:0)
这项工作对我来说:
在application / configs / application.ini
中resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
在application / Bootstrap.php
中class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* @return Zend_Application_Module_Autoloader
*/
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array('namespace' => '', 'basePath' => APPLICATION_PATH));
return $autoloader;
}
}
在modules / admin / Bootstrap.php
中class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
}
登录表单必须位于 modules / admin / forms 中,控制器位于 modules / admin / controllers 中。
我希望退房有帮助!
答案 2 :(得分:-1)
试试这个:
protected function _initAutoload() {
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH,
));
return $autoloader;
}
没有命名空间(只有你有一个名为Application _)。
至于配置文件:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
resources.layout.layout = "layout"
default.resources.layout.layoutPath = "/views/layout"
admin.resources.layout.layoutPath = "/views/layout"
[staging : production]
[testing : production]
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1