CakePHP - Class 'AuthComponent' not found in cached view
Asked Answered
D

2

5

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

Defoliate answered 2/7, 2013 at 7:19 Comment(0)
R
11

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

Ruscio answered 2/7, 2013 at 8:20 Comment(0)
J
0

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"

Jiggerypokery answered 5/11, 2020 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.