简体   繁体   中英

PHP: Phing, Phar, and phar.readonly

I'm using the PHP build system phing to create a phar archive file.

Is there any known science that will let me automatically set the phar.readonly to 0 (which will allow the creation of phar to know) during a run of phing , but leave it set to 0 at all other times?

phar.readonly can only be set in PHP.INI

Their documentation says it can be set by ini_set() ("phar.readonly "1" PHP_INI_ALL"), but it cannot.

$ php -r "ini_set('phar.readonly',0);print(ini_get('phar.readonly'));" 1

Update from http://php.net/manual/en/phar.configuration.php

This setting can only be unset in php.ini due to security reasons. If phar.readonly is disabled in php.ini, the user may enable phar.readonly in a script or disable it later. If phar.readonly is enabled in php.ini, a script may harmlessly "re-enable" the INI variable, but may not disable it.

short answer: You should set phar.readonly the parameter in your php.ini file from 1 to 0.

long answer: I have my PHP running on docker and for rewrite phar.readonly , I set an INI file in the dockerfile

RUN echo 'phar.readonly=0' >> /usr/local/etc/php/conf.d/docker-php-phar-readonly.ini

docker will read every INI file that you put in /usr/local/etc/php/conf.d/ folder and will rewrite php.ini with these parameters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM