0

I'm getting

Fatal error: Class 'Form_Login' not found in /route/to/project/application/controllers/AuthController.php on line XX

when instantiating the class From_Login inside the controller. I suppose the form is not being autoloaded by the bootstrap class. In my bootstrap file I have this method

protected function _initAutoload(){
        $modelLoader = new Zend_Application_Module_Autoloader(array(
                        'namespace' => '',
                        'basePath' => APPLICATION_PATH));
        return $modelLoader;
    }

supposed to autoload my resources. I'm using the default project structure.

-application
 --controllers
 ---Authcontroller.php
 --forms
 ---Login.php

when I created the form with zf tool it automatically set the name as Application_Form_Login then I erased the Application_ part since I'm using "" namespace. I doesn't work either way. I've also tried setting appnamespace="" in the application.ini file but nothing happened

Pratik
  • 11,534
  • 22
  • 69
  • 99
olanod
  • 30,306
  • 7
  • 46
  • 75
  • I found a similar question( http://stackoverflow.com/q/1572271/931340 ) solved by using Zend_Loader_Autoloader_Resource and then setting the paths and namespaces manually but it didn't worked for me. I've checked the folders and files names and they seem to be Ok – olanod Sep 13 '11 at 20:43
  • 1
    All looks ok - your bootstrap is at application/Bootstrap.php, right? (Might be worth checking that is being run), and the form class is defined as `Form_Login` in application/forms/Login.php? – Tim Fountain Sep 13 '11 at 23:08
  • Yes, that's why I ask, everything looks fine, I can for example instantiate a table in models/DbTable/Table.php – olanod Sep 14 '11 at 13:43

2 Answers2

0

After trying over and over different options I got tired because it didn't work so I erased the project folder and started from the beginning whit zend tool and ... voilà, it works! In my opinion it was a problem with zend tool and/or the .zfproject.xml file since I was adding some resources manually and some others with the zf tool.

olanod
  • 30,306
  • 7
  • 46
  • 75
  • There must have been something else affecting the class loading. The `.zfproject.xml` file is only read by the `zf` tool. The application does not use it at all. Glad you got it sorted anyway – Phil Sep 16 '11 at 05:26
0

use Zend modular structure and change your class name 'Form_Login' to 'Default_Form_Login' .

Mr Coder
  • 8,169
  • 5
  • 45
  • 74