1
votes

I just checked the error.log inside cake/app/tmp and found out that there's an error related with the `fa

2013-07-24 10:12:00 Error: [MissingControllerException] Controller class Favicon.icoController could not be found.

#0 C:\inetpub\wwwroot\app\webroot\index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))

#1 C:\inetpub\wwwroot\index.php(42): require('C:\inetpub\wwwr...')

#2 {main}

Im confused, as I am able to see the favicon on my site and it is located in webroot/img with the rest of images of the site. I am using a .png format.

Also, there's a default favicon in webroot called favicon.ico which I believe is the CakePHP one.

This is the way I'm loading my own favicon in my layout header:

echo $this->Html->meta('icon', $this->Html->url('/img/favicon.png'));

What is this problem pointing out?

2

2 Answers

1
votes

favicon.ico does not exist

By default there is the following route in CakePHP:

/:controller

If a request is made for a file that does not exist, it will manifest itself as a missing controller error. For example requesting a file that exists "just works":

$ pwd
/var/www/2.x/app/webroot
$ls
css  favicon.ico  files  img  index.php  js  test.php
$ curl -I http://cakephp.2.dev/favicon.ico
HTTP/1.1 200 OK
Date: Wed, 24 Jul 2013 11:25:07 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Wed, 24 Jul 2013 11:25:07 GMT
ETag: W/"1c7-174-4e2402c11f000"
Accept-Ranges: bytes
Content-Length: 372
Content-Type: image/x-icon

Removing the file results in a 404:

$ rm favicon.ico
$ curl -I http://cakephp.2.dev/favicon.ico
HTTP/1.1 404 Not Found
Date: Wed, 24 Jul 2013 11:26:52 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.17RC1
Set-Cookie: CAKEPHP=0h68rnghqaku6d8eo30od1ga06; expires=Wed, 24-Jul-2013 15:26:53 GMT; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 2861
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8

To be expected, but not just that, the error message generated is for a missing <file>Controller:

$ curl -i http://cakephp.2.dev/favicon.ico
...
<em>Favicon.icoController</em> could not be found.</p>

Therefore - to get the error message in the question - the file does not exist (or cannot be read due to file permissions).

0
votes

Try without Html::url and add type:

$this->Html->meta('icon', '/img/favicon.png', array('type' => icon');