[Phar]
phar.readonly = Off
<?php
$exts = array(
'*',
);
$dir = __DIR__;
$file = 'test.phar';
$phar = new Phar(__DIR__ . '/' . $file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $file);
$phar->startBuffering();
foreach ($exts as $ext) {
$phar->buildFromDirectory($dir, '/\.' . $ext . '$/');
}
$phar->delete('build.php');
$phar->setStub($phar->createDefaultStub('index.php'));
$phar->stopBuffering();
echo "打包完成".PHP_EOL;
b. 执行压缩脚本:
php /home/lee/php/compress.php
c. 查看压缩包:
ll /home/lee/php
<?php
define('ROOT',__DIR__);
$dir = ROOT.'/extract';
if(!is_dir($dir)){
@mkdir($dir);
}
$phar = new Phar(ROOT.'/test.phar');
$phar->extractTo($dir,null,true);
echo "解压完成".PHP_EOL;
b. 执行解压脚本:
php /home/lee/php/depress.php
c. 查看解压文件:
ll /home/lee/php/extract
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。