在新浪sae中 配置smarty
来源:互联网 发布:平板电脑无法加入网络 编辑:程序博客网 时间:2024/05/17 21:58
今天开始在新浪sae中配置smarty,按照在本地配置照搬到sae上,结果报错:
SAE_DEBUG: Smarty error: the $compile_dir './template_c' does not exist, or is not a directory.
在网上查了一下,大体上说原因是 SAE由于考虑到安全和分布式问题,所以本地IO写是禁止的,之后也查了百度 可是大部分都是转载的 都没有成功.
也没找到专门的sae版本的smarty, 只能修改其源码结合memcache来兼容了. 我用的是smarty3
1. 打开sae中你的应用,点击左下方服务管理中的Memcache,然后点击初始化,设置好容量大小(我设置为16M),这样,Memcache就配置好了。
2.在你的入口index.php 初始化memcache
<?php
//这段代码要放在入口文件
global $mmc; //设为全局变量 这样smarty才能访问
$mmc = new Memcache;
$ret = $mmc->connect();
if ($ret == false) {
echo "缓存开启错误\n";
exit;
}
$ret = $mmc->connect();
if ($ret == false) {
echo "缓存开启错误\n";
exit;
}
?>
3.更改smarty配置文件中的编译目录和缓存随意就行
$smarty->compile_dir = 'compile_dir';
$smarty->cache_dir = 'cache_dir';
4.修改 smarty/internals/core.write_compiled_resource.php 里面的 smarty_core_write_compiled_resource 函数为下面的格式
function smarty_core_write_compiled_resource($params, &$smarty)
{
$_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty);
return true;
}
{
$_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty);
return true;
}
5.修改 smarty/internals/core.write_file.php 里面的 core.write_file.php 函数为下面的格式
function smarty_core_write_file($params, &$smarty)
{
global $mmc;
$file = $params['filename'];
$content = $params['contents'];
$mmc->set("$file", $content);
return true;
}
{
global $mmc;
$file = $params['filename'];
$content = $params['contents'];
$mmc->set("$file", $content);
return true;
}
6.最后修改 Smarty.class.php里的一些代码 我的版本是在1264行 你们可以自己搜索下
if ($this->_is_compiled($resource_name, $_smarty_compile_path) || $this->_compile_resource($resource_name, $_smarty_compile_path))
{
{
//include($_smarty_compile_path); //这是源代码
include("saemc://".$_smarty_compile_path); //这是修改后的
}
include("saemc://".$_smarty_compile_path); //这是修改后的
}
7.这样大概就可以了 假如还是出错 那继续就一步一步的修改吧. 或者联系我
0 0
- 在新浪sae中 配置smarty
- 新浪云SAE SpeedPHP配置Smarty
- 新浪SAE中如何使用smarty模板
- Smarty For Sae(sae中使用smarty)
- 新浪sae配置weiphp记录
- 新浪云SAE---git配置
- 如何在SAE中使用smarty模板,实现MVC开发模式
- thinkphp在新浪SAE平台的部署
- thinkphp在新浪SAE平台的部署
- 在新浪sae下部署python程序数据库配置问题 an integer is required
- 在Ubuntu 14中安装配置smarty
- 新浪SAE中MySQL的连接
- Django在新浪SAE中使用storage服务实现文件上传保存
- 在sae配置django项目
- 微信公众号+Flask+新浪SAE 配置
- 新浪sae上php部署 应用配置及日志系统
- 新浪云计算丛磊:NoSQL在SAE中的应用
- 在新浪SAE上搭建自己的Discuz!
- android 轮番图——viewpager实现(自动轮番,手动轮番);bug汇总以及解决
- android自定义view控件之一圆角背景TextView
- 找主元素
- c语言 split函数的实现
- 数据结构第1章上机实验题
- 在新浪sae中 配置smarty
- [26] Vijos P1978 神奇的幻方(模拟)
- 入侵检测技术的实现
- C++中的智能指针...
- Twisted与异步编程入门
- Java基础思维导图大纲
- 入侵检测体系结构
- 机器学习算法疗程(EM)
- BNU单向行走 (贪心)