phar

xiaoxiao2021-02-28  29

C#可以把代码打包成dll java可以把代码打包成jar 那么凭什么PHP不可以?实际上在PHP5.3之后就出现了类似的东西叫做phar

新建build.txt:

<?php $phar = new Phar("test.phar"); $phar->buildFromDirectory(__DIR__.'/files','/\.php$/'); //编译files目录下的所有.php文件 $phar->compressFiles(Phar::GZ); $phar->setStub($phar->createDefaultStub('index.php')); //设置入口文件 123456

php命令行执行上面文件

php build.txt 1

然后命令行执行:

php test.phar 1

就会运行files目录下的正常代码逻辑

转载请注明原文地址: https://www.6miu.com/read-2249955.html

最新回复(0)