Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.