作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我将 CacheHelper 添加到我的应用程序中。在我的 APP/Config/core.php 中有
Configure::write('Cache.check', true);
在 APP/Config/bootstrap.php 我有
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));
在我的 Controller 中我有:
public $helpers = array('Text', 'Cache');
public $cacheAction = "1 hour";
我没有直接在此 Controller 或 AppController 中进行任何回调。问题是每个页面只加载一次(例如——在缓存被清除之后)。在第二次请求时我回来了
Fatal Error
Error: Class 'AppController' not found
如果关闭缓存,一切正常。
CakePHP 版本为 2.2.3
调试日志:
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}
新闻 Controller :
<?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";
最佳答案
获胜者是...App::uses('AppController', 'Controller');在 Controller 代码的顶部。
App::uses('AppController', 'Controller');
class NewsController extends AppController {
public $helpers = array('Cache');
public $cacheAction = array(
'index' => 48000
);
public function index() {
}
public function clear() {
clearCache();
}
}
我不知道为什么这还没有包含在食谱中。
关于php - CakePHP cacheHelper - 找不到 appController 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14018700/
我将 CacheHelper 添加到我的应用程序中。在我的 APP/Config/core.php 中有 Configure::write('Cache.check', true); 在 APP/Co
我是一名优秀的程序员,十分优秀!