-->

如何使一个可执行药业?(How to make an executable phar?)

2019-07-30 00:02发布

我想直接做启动脚本药业作为一个可执行文件, foo.phar <params> ,而不是php foo.phar <params>

Answer 1:

这是通过修改缺省短线(加上与PHP的家当)容易。

// start buffering. Mandatory to modify stub.
$phar->startBuffering();

// Get the default stub. You can create your own if you have specific needs
$defaultStub = $phar->createDefaultStub('index.php');

// Adding files
$phar->buildFromDirectory(__DIR__, '/\.php$/');

// Create a custom stub to add the shebang
$stub = "#!/usr/bin/php \n".$defaultStub;

// Add the stub
$phar->setStub($stub);

$phar->stopBuffering();


文章来源: How to make an executable phar?
标签: php shebang phar