So I am working on a sample database project.
I have a LoginController.php, a Faculty database, and a login page (phtml).
I get the error Fatal error: Class ‘Faculty_DB’ not found in /usr/local/zend/apache2/htdocs/InternProject1/application/controllers/LoginController.php on line 25
In the LoginController.php I have the following (plus some more):
public function indexAction()
{
$login = new Form_Login();
//$this->view->login = $login;
$request = $this->getRequest();
if($request->isPost())
{
$data = $request->getPost();
//$this->isValid(
if($this->getRequest()->getPost())
{
$username = $request->getParam('username');
$password = $request->getParam('password');
// echo " What you entered is: $username and $password";
//line 24
$faculty = new Faculty_DB();
//then conditions for validation.
This references
class Faculty_DB extends Zend_Db_Table_Abstract
which is located in application/models/ directory
I have the following in Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoLoader->registerNamespace(array('App_'));
$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => '',
'resourceTypes' =>
array('form'=>
array('path' => 'forms/',
'namespace' => 'Form_'
),
),
));
return $autoLoader;
}
}
Any clue on how to fix this?
I tried the following:
protected function _initResourceAutoloader()
{
$autoloader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => 'Application',
));
$autoloader->addResourceType( 'model', 'models', 'Model');
return $autoloader;
}
but when I do that, it tells me it can’t find my Login_Form;
Given that your application namespace is
Application, try:application/models/Faculty.phpApplication_Model_FacultyApplication_Model_DbTable_Facultyapplication/models/DbTable/Faculty.phpSince you are using
Zend_Application, it will take care of setting up the autoloader and special prefixes likeForm_,Model_,Plugin_etc for you, so you can safely remove the_initAutoloadand_initResourceAutoloaderfrom your Bootstrap.