Jump to content

ZF: Class not found?


deerly

Recommended Posts

Hello!

 

I am new to ZF and MVC in general and am working on my very first ZF application which at the moment is entirely a learning effort.

 

My question is regarding experimenting with this tutorial: Login and Authentication with Zend Framework - phly, boy, phly

 

I put the LoginForm class in a file called Login.php in /applications/forms

 

However, when i call getForm() I receive the following error:

 

Fatal error: Class 'LoginForm' not found in /home/gurriburd/dev/application/controllers/LoginController.php on line 7

 

Seems that it cannot locate the form. I'm wondering if there is a basic naming convention or expectation that I am overlooking.  ??? Thanks so much!

Link to comment
https://forums.phpfreaks.com/topic/164731-zf-class-not-found/
Share on other sites

Try naming the class Default_Form_Login, keeping filename and place the same.  If this doesn't work, you'll have to set up a specific autoloader.

 

If you're using Zend_Application_Module_Autoloader (as they do in the quickstart guide) then the example they provide should work (I haven't tested).  Insert the following function into your bootstrap.

<?php
protected function _initAutoload(){
    $autoloader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'Default_',
        'basePath'  => dirname(__FILE__),
    ));
    return $autoloader;
}

 

I'm actually using Zend_Loader_Autoloader (for more complex things) - below is how I solve it.

<?php
protected function _initAutoload(){
    $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
        'basePath'  => APPLICATION_PATH, //APPLICATION_PATH is is folder Bootstrap.php is in
        'namespace' => 'Default',
    ));
    $resourceLoader->addResourceType('form','forms/','Form');
}

Link to comment
https://forums.phpfreaks.com/topic/164731-zf-class-not-found/#findComment-869480
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.