我已經嘗試了許多不同的方法來解決這個問題,我已經在網上找到,但他們沒有工作,所以請有人可以幫助我。如何在類中加載模塊的控制器?
我收到此錯誤
致命錯誤:類 'Admin_Form_Login' 在pathToProject /模塊/管理/控制器沒有找到/ LoginController.php上線13
我的項目是
應用
---模塊
------管理
個--------控制器
--------形成
--------車型
--------意見
------默認
--------控制器
--------形成
--------車型
--------意見
------公司簡介
--------控制器
--------形成
--------車型
--------意見 等 等
我的控制器
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;
}
}
這裏是我的應用程序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
和我的六ew
$this->form
感謝您的任何幫助。
我在生產部分添加了以下內容確定我的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"
您的'Admin_Bootstrap',大概存儲在'application/modules/admin/Bootstrap.php'中,擴展了'Zend_Application_Module_Bootstrap',它註冊了自己的資源自動加載器。你可能會刪除你自定義的'Admin_Bootstrap :: _initAutoload()'方法。 –
你的表單類是在'application/modules/admin/forms/Login.php'嗎? –
是的,它是在應用程序/模塊/管理/形式/登錄.php – David