View Single Post
  #1 (permalink)  
Old 04-04-2008, 12:22 PM
davidmpaz davidmpaz is offline
Junior Member
 
Join Date: Mar 2008
Posts: 8
Default Cannot load controller class

Hi,
I really need help.
I've been all the week trying to setting up a simple single module MVC project with Zend_Controller and Smarty, I want to start using it from now and on and when I thought I get it, having three controller working ok (Index Error and Login Controller), I added another one and started to get this exception message when pointing my browser to:

http://localhost/ahome/work2/user/show-user


Cannot load controller class "UserController" from file "UserController.php" in directory "C:\xampp\htdocs\ahome\work2\application/controllers"

My directory structure is like this:
Code:
...work2/
           index.php
          .htaccess
          application/
                         controllers/
                                       generated/
                         views/
                                configs/
                                templates/
                                templates_c/  
                         models/
                         libs/
the UserController code is:

PHP Code:
<?php
    
//Imlementation file, you MUST modify this!

    
require_once dirname(__FILE__).'/generated/UserController_Abstract.php';
    
    
/**
     * Concrete class doing the custom stuff
     * Create the templates needed to work with this
     * in the application/views/templates directory
     */
    
class UserController extends UserController_Abstract
    
{
        
        protected function 
handleShowUserAction($theView)
        {
            die(
"Function handleShowUserAction(theView), Not Implemented. ");
        }
        
        
        
        public function 
__construct()
        {
            
parent::__construct();
        }
        
    }
    
?>
and the UserController_Abstract:

PHP Code:
<?php
    
//Generated file, do not modifiy by hand.
    
    
require_once dirname(__FILE__).'/../../common.app.inc.php';
    require_once 
ZEND_HOME.'Controller/Action.php';
    require_once 
APP_HOME.'Zend_View_Smarty.php';
    require_once 
MODELS_HOME.'Factory.php';
    
    
/**
     * Abstract class for subclassing
     */
    
abstract class UserController_Abstract extends Zend_Controller_Action
    
{
      
        
/**
         * Keeps reference to UserService
         */
        
private $userService;
        
        
//Getter method for Attribute of type: UserService
        
public function getUserService()
        {
            return 
$this->userService;
        }
        
        
        
//Setter method for Attribute of type: UserService
        
public function setUserService($newValue)
        {
            
$this->userService $newValue;
        }
        
          
        public function 
init()
        {
            
// Since using Smarty not needed.
            
$this->_helper->viewRenderer->setNoRender(true);
        }
    
        public function 
preDispatch()
        {
            
//Verify if user is authenticated
            
require_once ZEND_HOME.'Auth.php';
            
$auth Zend_Auth::getInstance();
            if (! 
$auth->hasIdentity())
                
//Redirected to generated login controller
                
$this->_forward('login''login');
        }
    
        
        
/**
         * ShowUser action
         */
        
public function showUserAction()
        {
            
//Create the Smarty View Wrapper
            
$view = new Zend_View_Smarty();
            
$view->setScriptPath(VIEWS_HOME);
             
            
//Assign variables here
            
handleShowUserAction($view);
            
            
//Display the view (i.e. the Smarty Template)
            
$view->render('showUser.tpl');
        }
          
        
/**
         * Handler to do custom things in action, assigning variables
         * or get/set request parameters to redirect to other action, etc...
         * override it in: User class.
         */
        
        
abstract protected function handleShowUserAction($theView);
        
        
        public function 
noRouteAction()
        {
            
$this->_redirect('/');
        }
        
        
/**
         * Initialize the services, called from UserController 
         */
        
public function __construct()
        {
            
$this->userService Factory::newInstance(USERSERVICE);
        }
        
    }
    
?>
the bootstrapping file is this:

PHP Code:
//For the case of zend framwork not being in include_path, 
    //if it is, this is not needed.
    //set_include_path('.' . PATH_SEPARATOR . 'application/libs/zend' . PATH_SEPARATOR . get_include_path());
    
    
require_once dirname(__FILE__).'/application/common.app.inc.php';
    require_once 
ZEND_HOME.'Controller/Front.php';
 
    
$front Zend_Controller_Front::getInstance();
    
$front->setParam('useDefaultControllerAlways'true);
    
$front->setControllerDirectory(CONTS_HOME);
    
    
$front->dispatch(); 
and the .htaccess is the same as in docs. As i said other three controllers are working fine, redirecting ok, and also rendering the templates. The mod_rewrite is working in my server too.
I know that this could be a simple thing to solve, it is just I can realize what is (Two days trying to figure it out and now I get lost ).

Please any idea would be great, Sorry if it is a too long post.

Thanks.
Reply With Quote