5
votes

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

2

2 Answers

11
votes

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).

0
votes

That would be this line in the file \config\bootstrap.php

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

Note that I tried this in Cake 4.1.5 but it tlls me "Class 'AuthComponent' not found"