Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp - Controller not found

I keep getting this error... Wondering what this means

Error: [MissingControllerException] Controller class CssController could not be found.

any suggestions?

like image 378
Bahdeng Avatar asked Mar 05 '13 17:03

Bahdeng


2 Answers

You seem to be either missing the 'css' directory in your webroot or a misconfigured mod_rewrite;

The default CakePHP mod_rewrite configuration will 'route' non-existing directories/files to Controllers and Actions, e.g.

/some/path

Will be routed to

SomeController::path()

If you dont have a 'css' directory in your webroot, then;

/css/

Will be routed to:

CssController::index()

However, since there's no such controller in your application, it will give this error.

like image 114
thaJeztah Avatar answered Oct 30 '22 01:10

thaJeztah


A little tip for those debugging this problem.

thaJeztah is absolutely right regarding why that error appears, but for debugging purposes it's kind of difficult to know where is the offending css path causing this.

If you use $this->Html->css('path') to load your css files (obviously with the correct path), and you have your css folder within webroot as already stated in the other answer, then check you css files.

In my case, I debugged with firebug, but all my .css where loading, there was no red error indicating that a css file couldn't load (which could be the causing this problem). So I checked my css files and the urls for background where pointing to a nonexistent folder

Example:

//Webroot folder dist
-- css
-- extras
   --img

mydiv {
    background: #626262 url(../img/web_top_bg.png);
}

So clearly the image wasn't loading, but I didn't notice because it wasn't an element that got instantiated often. Resolving that url() reference got rid of the CssController error (and also, related, got rid of this other annoying error regarding multiple request for the same page only in some browsers (isn't it great when you have to debug those things...)).

Hope this helps someone.

like image 43
Nunser Avatar answered Oct 30 '22 02:10

Nunser