升级系统后PHP和Smarty编译延迟

升级系统后PHP和Smarty编译延迟,php,ubuntu,smarty,delay,Php,Ubuntu,Smarty,Delay,将我的Xubuntu从13.04升级到13.10后,Smarty和PHP出现问题错误 基本上,Smarty模板在我编辑模板后以5-7秒的延迟重新编译 我比较了系统时间(date)和PHP的date(…),时间戳是相等的 PHP版本5.5.3-1ubuntu2 如何修复它 示例代码: require_once 'classes/Smarty-3.1.8/libs/Smarty.class.php'; $tpl = new Smarty(); // if I edit this templ

将我的Xubuntu从13.04升级到13.10后,Smarty和PHP出现问题错误

基本上,Smarty模板在我编辑模板后以5-7秒的延迟重新编译

我比较了系统时间(
date
)和PHP的
date(…)
,时间戳是相等的

PHP版本5.5.3-1ubuntu2

如何修复它

示例代码:

require_once 'classes/Smarty-3.1.8/libs/Smarty.class.php';

$tpl = new Smarty();    
// if I edit this template, changes shows up after
// 3-4 seconds which is very annoying
// there was no issue in xubuntu 13.04 / older php version!
$tpl->display('test.tpl'); 
编辑:

我仔细检查了
filemtime
是否正常工作。我找到了解决方案

另外,xubuntu 13.10提供的最新PHP默认启用了zend opcache,这导致了问题

我必须更改php的配置:

opcache.enable=0

现在一切都好了,编辑后立即编译模板。

您可以启用opcache并设置:

opcache.revalidate_freq=0
问题在于,默认情况下,opcache仅在2秒后检查时间戳,smarty编译的模板是在同一请求期间生成的,因此不会进行检查

将opcache revalidate_freq设置为0会使opcache每次都检查所有文件的时间戳,因此在.tpl文件中所做的更改会立即显示出来

编辑:我相信从Smarty v3.1.29开始,这不再是必需的