手机
当前位置:查字典教程网 >编程开发 >php教程 >sae使用smarty模板的方法
sae使用smarty模板的方法
摘要:Smarty是非常流行的模板系统,它分离了业务和逻辑、执行速度快,在php网站中有广泛的运用。不过在部署到sinaappengine(sae...

Smarty是非常流行的模板系统,它分离了业务和逻辑、执行速度快,在php网站中有广泛的运用。

不过在部署到sina app engine(sae)上时出现了问题,因为sae作为云计算平台式无法进行文件读写操作的,所以Smarty中输出的缓存文件就无法实现。

错误信息:“SAE_Fatal_error: Uncaught exception 'SmartyException' with message 'unable to write file ./web/templates_c/wrt4e95555280ef1' ”

SAE给出了解决方案就是使用Memcache。首先进入应用中的应用管理中,在服务管理中开启Memcache一个初始化,

然后修改Smarty的配置文件:

复制代码 代码如下:

// For SAE 编译文件存放在memcache中

$smarty->compile_dir = 'saemc://smartytpl/';

$smarty->cache_dir = 'saemc://smartytpl/';

$smarty->compile_locking = false; // 防止调用touch,saemc会自动更新时间,不需要touch

上面三行是必须的。

这样Smarty模板就可以在SAE上运行了。

【sae使用smarty模板的方法】相关文章:

PHP调用三种数据库的方法(3)

PHP生成plist数据的方法

php中smarty区域循环的方法

PHP date函数常用时间处理方法

PHP准确取得服务器IP地址的方法

用PHP制作静态网站的模板框架

php生成圆角图片的方法

php使用curl打开https网站的方法

PHP调用三种数据库的方法(2)

PHP遍历数组的方法汇总

精品推荐
分类导航