1、打包文件 phar_test_gz.php
$phar_file = '../phar_test.phar'; if (file_exists($phar_file)) unlink($phar_file); $phar = new Phar($phar_file); $phar->buildFromDirectory(__DIR__); $phar->compressFiles(Phar::GZ); $phar->stopBuffering(); $phar->setStub($phar->createDefaultStub('./public/index.php'));
php phar_test_gz.php
2、运行文件 phar_test.php,RUNTIME_PATH定义在外部,phar里不能创建临时文件夹
define('RUNTIME_PATH', __DIR__.'../phar_test_runtime/'); require_once "../phar_test.phar";
3、url访问,php_test为thinkphp5项目文件夹,thinkphp5.1不支持RUNTIME_PATH定义在外部,暂时没测试
http://127.0.0.1/php_test/php_test.php/index/index/index