thinkphp如何设置runtime文件的存储路径!

2025-03-11 02:54:50
推荐回答(2个)
回答1:

ThinkPHP的编译缓存文件runtime.php:
1.定义单入口文件(index.php)
在单入口index.php中不定义这两项时,会生成编译缓存文件~runtime.php
define('RUNTIME_PATH','./App/Temp/'); //定义编译目录
define('APP_DEBUG',TRUE); //开启调试模式

上述两行不能在index.php中作用,则index.php变为
define('APP_NAME','App'); //项目名称
define('APP_PATH','./App/'); //项目路径
include './ThinkPHP/ThinkPHP.php'; //引入ThinkPHP核心运行文件
?>

2.生成编译缓存文件(~runtime.php)
3.复制~runtime.php中的全部内容到index.php中,运行效果会和之前一样。
~runtime.php中缓存的编译内容,相当于把index.php引导的所有操作全部集成到~runtime.php文件中。
有了这个缓存的编译文件,index.php在下次运行时,不再引导,而是直接检测是否存在~runtime.php编译缓存文件,如果在,则直接运行~runtime.php。

回答2:

修改 Tinkphp.php中的

defined('RUNTIME_PATH') or define('RUNTIME_PATH',   '/Runtime/');   // 系统运行时目录

此宏为tp的runtime目录