Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP - Class 'AuthComponent' not found in cached view

I'm using CakePHP 2.3. and I'm trying to cache my home page view. But After caching it to home.php, I can't load cached view because of error:

Error: Class 'AuthComponent' not found
File: C:\wamp\www\project\trunk\app\tmp\cache\views\home.php
Line: 87

I use AuthComponent for realizing if user is logged in or not. Without caching Everything works.

Controller code:

public $helpers = array('Cache');

public $cacheAction = array(
   'home' => '60 minutes',
);

Thanks

like image 237
vlcik Avatar asked Jul 02 '13 07:07

vlcik


1 Answers

App::uses() your Auth component in your bootstrap would help:

App::uses('AuthComponent', 'Controller/Component');

This way Cake knows where to load the class from if its needed (even in cache mode).

like image 151
mark Avatar answered Oct 16 '22 17:10

mark