Controller file was loaded but class does not exist
Asked Answered
B

4

18

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}
Bostwick answered 4/2, 2010 at 19:18 Comment(2)
If you include 1. The full path to your created controller file and 2. the contents of your controller file, people will be better able to help you.When
Here we have some update. Please check here, It will help youUnhook
W
40

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).

Wein answered 4/2, 2010 at 20:54 Comment(0)
Z
22

Hope you got this sorted, just to let you know I looked at the same tutorial, and I think this error may be fixed by the addition of the <?php declaration to the start of the php code samples.

Zygosis answered 9/9, 2011 at 11:49 Comment(2)
This was exactly my problem; I copied and pasted directly from the tutorial and couldn't figure out where I was going wrong...thanks!Outthink
Me too , Because i am making same mistakeBracknell
W
15

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
When answered 28/12, 2010 at 21:16 Comment(0)
N
3

I was getting this error because I was using following code in my CartController(Overridden)

require_once "Mage/Checkout/controllers/CartController.php"; 
class Muk_Mycart_CartController extends Mage_Core_Controller_Front_Action
{
}

instead of following code of line

require_once "Mage/Checkout/controllers/CartController.php"; 
class Muk_Mycart_Checkout_CartController extends Mage_Core_Controller_Front_Action
{
}

I was missing "Checkout" in "Muk_Mycart_CartController".This is error because I was using following code in my CartController(Overridden)

My directory structure was like this

\app\code\local\Muk\Mycart\controllers\Checkout
\app\code\local\Muk\Mycart\controllers\Checkout\CartController.php
Nicosia answered 1/3, 2013 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.