Please explain how to create PHP's Phar stubs

安稳与你 提交于 2019-12-03 05:00:54

To answer my own question.

The method outlined in my question, above, is one correct way to create a phar / phar stub.

The reason why it did not work for me and did work for Mario (see his comment below the question), is because I had Suhosin installed and needed to tweak the settings.

Fixed using the technique outlined here:

To fix, put:

suhosin.executor.include.whitelist="phar"

in /etc/php5/cli/php.ini

you could also do it like this:

bootstrap.php;

<?php
function go() {
    print phpversion() . PHP_EOL;
    print 'i am some script' . PHP_EOL;
}

then:

php -r "require 'phar://Myproject.phar'; go();"

or don't have a function and it will execute whatever commands you have in there, but typically you would have some functions or class files in the phar.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!