Fix for CakePHP error: Fatal error: Class ‘Router’ not found in xxxx
Let me guess, you just moved servers or directories, right? Fortunately it’s an easy fix.
Cake keeps caches of computationally expensive data in order to reduce CPU and memory use and speed your applications up. The downside is occasionally, such as after a server move, Cake caches something you really don’t want cached. In this case the absolute pathname to the CakePHP router.php file.
Fortunately the solution is easy. Just clear your cache by deleting all the files in tmp/cache and tmp/cache/models. The problem should instantly be gone.
Written by Jasson Cascante
Related protips
3 Responses
Did not work
Did not work for me either. Where else does cake cache stuff? What calls the router::connect method in routes.php?
You are missing a use statement. Because CakePHP 3.0 uses namespaces, you have to either use the fully namespaced classname Cake\Routing\Router or add use Cake\Routing\Router to the top of your view file.