CakePHP cacheHelper - appController error not found

I added CacheHelper to my application. In my APP / Config / core.php I have

Configure::write('Cache.check', true); 

In APP / Config / bootstrap.php I have

 Configure::write('Dispatcher.filters', array( 'AssetDispatcher', 'CacheDispatcher' )); 

In my controller, I:

 public $helpers = array('Text', 'Cache'); public $cacheAction = "1 hour"; 

I do not have callbacks directly in this controller or in AppController. The problem is that each page only loads once (for example, after clearing the cache). At the second request, I return

 Fatal Error Error: Class 'AppController' not found 

If the cache is disabled, everything works fine.

CakePHP Version - 2.2.3

Debug Log:

  2012-12-24 12:21:00 Error: Fatal Error (1): Class 'AppController' not found in [/Volumes/../app/Controller/NewsController.php, line 2] 2012-12-24 12:21:00 Error: [FatalErrorException] Class 'AppController' not found #0 /Volumes/../lib/Cake/Error/ErrorHandler.php(161): ErrorHandler::handleFatalError(1, 'Class 'AppContr...', '/Volumes/Data/D...', 2) #1 [internal function]: ErrorHandler::handleError(1, 'Class 'AppContr...', '/Volumes/../D...', 2, Array) #2 /Volumes/../lib/Cake/Core/App.php(926): call_user_func('ErrorHandler::h...', 1, 'Class 'AppContr...', '/Volumes/../D...', 2, Array) #3 /Volumes/../lib/Cake/Core/App.php(899): App::_checkFatalError() #4 [internal function]: App::shutdown() #5 {main} 

NewsController:

 <?php class NewsController extends AppController { public $components = array('Security', 'ImageTool', 'Uploader'); public $paginate = array( 'fields' => array('News.id', 'News.created'), 'limit' => 5, 'contain' => array(), 'order' => array('News.id' => 'DESC')); public $helpers = array('Text', 'Cache'); public $cacheAction = "1 hour"; 
+7
source share
2 answers

And the winner ... App :: uses ('AppController', 'Controller'); at the top of the controller code.

 App::uses('AppController', 'Controller'); class NewsController extends AppController { public $helpers = array('Cache'); public $cacheAction = array( 'index' => 48000 ); public function index() { } public function clear() { clearCache(); } } 

I do not know why this is not yet included in the Cookbook.

+19
source
 <?php namespace App\Controller; use App\Controller\AppController; class StudentsController extends AppController{} 

This worked for me.

0
source

All Articles