Controller file was loaded but class does not exist

Viewed 16558

I am having trouble getting around this error in Magento:

"Controller file was loaded but class does not exist". (Full stack at bottom)

I am essentially trying to follow this tutorial: Create new module “HelloWorld” – in Magento.

...though I am using my own company/class names etc. instead of "hello world"

I am having trouble finding good documentation on Magento in general, and I am very new at it...

can anyone provide some common causes, advice, or insight? I am swamped, googled this for hours, check permissions and file structure. You name it.

Trace:
#0 /var/www/dev/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(306): Mage::exception('Mage_Core', 'Controller file...')
#1 /var/www/dev/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(282): Mage_Core_Controller_Varien_Router_Standard->_inludeControllerClass('/var/www/dev_ml...', 'Foo_Wr...')
#2 /var/www/dev/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(195): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName('foo_Wr...', 'index')
#3 /var/www/dev/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#4 /var/www/dev/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#5 /var/www/dev/index.php(65): Mage::run()
#6 {main}
4 Answers

That error means that magento found a file for your controller where it expected to (app/code/local/Namespace/Module/controllers/FooController.php) but that the class inside didn't have the name it expected (it wasn't Namespace_Module_FooController).

You might find this article, (part of a larger series) (self-link) more helpful, and it goes more into the why of what you're doing, which will enable you to better debug things yourself in the future.

As for your specific error

Controller file was loaded but class does not exist

This means magento was able to correctly require/include the file you placed your controller in but the controller class was misnamed. Controllers should be named

Packagename_Module_ControllernameController

and located in the folder

app/code/local/Packagename/Modulename/controllers/ControllernameController.php
Related