可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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: .
...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}
回答1:
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).
回答2:
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.
回答3:
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
回答4:
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