Author Topic: Invalid controller class  (Read 1625 times)

0 Members and 1 Guest are viewing this topic.

Offline simpliTopic starter

  • Enthusiast
  • Posts: 164
    • View Profile
Invalid controller class
« on: June 01, 2009, 08:59:36 PM »
Hi,
I am trying to use my controller. When I put the path "http://budgetobjects/index.php" I get what I'm supposed to get. When I put http://budgetobjects/companyInfo, I get a  Message: Invalid controller class ("CompanyinfoController").

I have the following class described in the CompanyInfoController.php file.
Code: [Select]
<?php
// application/controllers/CompanyinfoController.php
class default_CompanyInfoController extends Zend_Controller_Action 
{
    public function 
indexAction()
    {
        
$companyInfo = new Default_companiesInformation();
        
$this->view->entries $companyInfo->fetchAll();
    }
}

Can anyone tell me what is wrong with my code?

Thanks,
JR

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Invalid controller class
« Reply #1 on: June 02, 2009, 05:08:54 AM »
Your definition should look more like...

class Default_CompanyinfoController extends Zend_Controller_Action

Caps are important.

Have you told Zend to explicitly add the Default_ namespace to your controllers?

Offline simpliTopic starter

  • Enthusiast
  • Posts: 164
    • View Profile
Re: Invalid controller class
« Reply #2 on: June 02, 2009, 07:00:51 AM »
I have told my bootstrap to use the default namespace
Code: [Select]
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctype()
    {
       
$this->bootstrap('view');
        
$view $this->getResource('view');
        
$view->doctype('XHTML1_STRICT');
    }

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


}


this is my application.ini file ( I am in the development environment)
Code: [Select]
[production]
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook-testing.db"

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/default/Controllers"
resources.layout.layoutPath = APPLICATION_PATH "/default/layouts/scripts"
resources.view[] =

and this is my tree structure. I remove all the cases in the class name, even in the file name. I still get the error.
the error i get is the following:
Exception information:

Message: Invalid controller class ("CompanyinfoController")
Stack trace:

#0 /Library/WebServer/Documents/Zend/library/Zend/Controller/Dispatcher/Standard.php(255): Zend_Controller_Dispatcher_Standard->loadClass('CompanyinfoCont...')
#1 /Library/WebServer/Documents/Zend/library/Zend/Controller/Front.php(936): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#2 /Library/WebServer/Documents/Zend/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#3 /Library/WebServer/Documents/Zend/library/Zend/Application.php(303): Zend_Application_Bootstrap_Bootstrap->run()
#4 /Library/WebServer/Documents/budgetObjects/public/index.php(26): Zend_Application->run()
#5 {main}
 

Request Parameters:

array(3) {
  ["controller"]=>
  string(11) "companyinfo"
  ["action"]=>
  string(5) "index"
  ["module"]=>
  string(7) "default"
}
 
 Do you notice that loadclass statement? It seems to still be looking for a CompanyinfoCon.. instead of companyinfo...

 Here is my tree structure.
Code: [Select]
|____.DS_Store
|____.zfproject.xml
|____application
| |____.DS_Store
| |____Bootstrap.php
| |____configs
| | |____application.ini
| |____default
| | |____.DS_Store
| | |____controllers
| | | |____companyinfoController.php
| | | |____ErrorController.php
| | | |____IndexController.php
| | |____layouts
| | | |____.DS_Store
| | | |____scripts
| | | | |____layout.phtml
| | |____models
| | | |____.DS_Store
| | | |____companiesInformation.php
| | | |____companiesInformationMapper.php
| | | |____DBTable
| | | | |____companies_information.php
| | |____views
| | | |____.DS_Store
| | | |____helpers
| | | |____scripts
| | | | |____.DS_Store
| | | | |____companyinfo
| | | | | |____index.phtml
| | | | |____error
| | | | | |____error.phtml
| | | | |____index
| | | | | |____index.phtml
|____index.php
|____js
| |____test.js
|____library
| |____zend
|____public
| |____.htaccess
| |____bkp simpleindex.php
| |____index.php
|____tests
| |____application
| | |____bootstrap.php
| | |____controllers
| | | |____CompanyInfoControllerTest.php
| |____library
| | |____bootstrap.php
| |____phpunit.xml

Thanks for any help

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Invalid controller class
« Reply #3 on: June 02, 2009, 07:04:32 AM »
Your controller needs to be named CompanyinfoController.php, not companyinfoController.php.

Offline simpliTopic starter

  • Enthusiast
  • Posts: 164
    • View Profile
Re: Invalid controller class
« Reply #4 on: June 02, 2009, 07:49:32 AM »
I have tried that  before and just did again, to no avail. I get the exaact same error message.
JR