Invalid error indicated by the controller, even if the controller is present

I have a camelcased controller name called MenuItem. And also I created a router for this particular controller as

$routeMenuItem = new Zend_Controller_Router_Route('/menu-item/:action/:menu/:parent/:id/*', array( 'controller' => 'MenuItem', 'action' => 'index', 'menu' => 1, 'parent' => 0, 'id' => 0 )); 

No, when I go to this route, say /menu-item/index/2 , I get an error, Invalid controller specified (MenuItem) .

However, I am facing this problem while deploying in linux environment . But during development on Windows, it works great .

How to solve this?

Additional Information

Controller:

 File Name: MenuItemController.php Class Name: MenuItemController 

Stack trace

 #0 /../library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /../library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /../library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /../public/index.php(25): Zend_Application->run() #4 {main} 

Request Parameters

 array ( 'action' => 'index', 'menu' => '2', 'controller' => 'MenuItem', 'parent' => 0, 'id' => 0, ) 
+4
source share
2 answers

This is due to the fact that Windows is not case sensitive, but Linux-based operating systems.

In the ZendFramework manual:

The Zend_Controllers dispatcher then takes the value of the controller and maps it to the class. By default, this is the Title-case name of the controller and adds the word Controller. Thus, in our example above, the controller roadmap is mapped to the RoadmapController class.

This means that MenuItemController.php and MenuitemController.php are two different things, so the autoloader cannot find a match.

Generally, when using verbose controllers, just make sure that only the first letter of the class and controller C are capitalized.

+1
source

I had a very similar problem in the past (I also developed on Windows and deployed the application on a Linux server). My solution was to rename classes and files to remove upper case. In your case, it will be:

 File Name: MenuitemController.php Class Name: MenuitemController 
0
source

All Articles