Zend Fatal error: Class 'Admin_Form_Login' not found

For programming and general questions on Zend Framework
Post Reply
davidtheo
Posts: 28
Joined: Fri Nov 11, 2011 11:41 pm

Zend Fatal error: Class 'Admin_Form_Login' not found

Post by davidtheo » Fri Aug 31, 2012 5:50 pm

I have tried many different ways to solve this that I have found online but they have not worked, so please can someone help me.

I am getting this error

Fatal error: Class 'Admin_Form_Login' not found in pathToProject/application/modules/admin/controllers/LoginController.php on line 13

my project is

Application

--- modules

------admin
--------controllers
-----------Controller Class
--------forms
----------form class
--------models
--------views
--------bootstrip class

------default
--------controllers
--------forms
--------models
--------views

------aboutus
--------controllers
--------forms
--------models
--------views etc etc

My Controller

Code: Select all

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
  }
}
My Form

Code: Select all

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 Bootstrip

Code: Select all

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;
}
}
My app.ini

Code: Select all

[bootstrap]
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"

;Database settings

	
[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
Also My default layouts for each module do not seem to be working but, that problem is not so important.



I would like any help anyone can give.

Thanks

us2rn4m2
Posts: 49
Joined: Mon Jun 18, 2012 12:41 am

Re: Zend Fatal error: Class 'Admin_Form_Login' not found

Post by us2rn4m2 » Fri Aug 31, 2012 9:34 pm

Hi,

Same question again and again ... :)

Ok, add this line in your _initAutoload method.

Code: Select all

$autoloader->addResourceType('forms', 'forms/', 'Form');
Final result:

Code: Select all

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",
    ));
    
    $autoloader->addResourceType('forms', 'forms/', 'Form');
    
    return $autoloader; 
}
more here: http://framework.zend.com/manual/en/zen ... ource.html
http://bit.ly/TattooEdit

davidtheo
Posts: 28
Joined: Fri Nov 11, 2011 11:41 pm

Re: Zend Fatal error: Class 'Admin_Form_Login' not found

Post by davidtheo » Fri Aug 31, 2012 10:14 pm

us2rn4m2 wrote:Hi,

Same question again and again ... :)

Ok, add this line in your _initAutoload method.

Code: Select all

$autoloader->addResourceType('forms', 'forms/', 'Form');
Final result:

Code: Select all

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",
    ));
    
    $autoloader->addResourceType('forms', 'forms/', 'Form');
    
    return $autoloader; 
}
more here: http://framework.zend.com/manual/en/zen ... ource.html

I added in

Code: Select all

$autoloader->addResourceType('forms', 'forms/', 'Form');
And I am still getting the same error

us2rn4m2
Posts: 49
Joined: Mon Jun 18, 2012 12:41 am

Re: Zend Fatal error: Class 'Admin_Form_Login' not found

Post by us2rn4m2 » Fri Aug 31, 2012 10:49 pm

In your application.ini cut all this stuff below and paste into [production]

Code: Select all

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"

;Database settings
http://bit.ly/TattooEdit

davidtheo
Posts: 28
Joined: Fri Nov 11, 2011 11:41 pm

Re: Zend Fatal error: Class 'Admin_Form_Login' not found

Post by davidtheo » Fri Aug 31, 2012 11:14 pm

us2rn4m2 wrote:In your application.ini cut all this stuff below and paste into [production]

Code: Select all

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"

;Database settings
This worked Thanks :)

Post Reply