Alana Storm
Alana Storm

Reputation: 166126

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?

Upvotes: 6

Views: 4938

Answers (2)

adnan ahmady
adnan ahmady

Reputation: 970

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

Upvotes: 1

AndovaBegarin
AndovaBegarin

Reputation: 81

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.

Upvotes: 8

Related Questions