Unable to enable phar writing

I actually use wamp 2.5 with PHP 5.5.12, and when I try to create a phar file, it returns me the following message:

Unable to throw "UnexpectedValueException" with the message "create archive" ... "disabled by php.ini setting phar.readonly '

even if I disable the phar.readonly option in php.ini.

So how can I enable the creation of phar files?

+9
source share
3 answers

I had the same problem and put together information from this thread, here is what I did in a simplified explanation:

  1. in my PHP code that generates this error, I added echo phpinfo(); (which displays a large table with all kinds of PHP information) and in the first few lines check the path to the php.ini file to make sure that you are editing the correct php.ini file.
  2. find on phpinfo() table where it says phar.readonly and note that on.
  3. open the php.ini file starting from step 1, and phar.readonly search for phar.readonly . Mine is on line 995 and reads ;phar.readonly = On
  4. Change this line to phar.readonly = Off . Make sure there is no semicolon at the beginning of the line.
  5. Reboot your server
  6. Make sure your phar project is now working properly, and / or search the 'phpinfo () table again to see that the phar.readonly parameter has changed.
+1
source

phar.readonly can only be disabled in php.ini for security reasons. If you want to verify that this is not really done using a method other than php.ini , then type this in the terminal: -

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

If it gives you 1 means phar.readonly is On .
More on phar.configuration

+2
source

Need to disable in php.ini

Enter which php /c/Apps/php/php-7.2.11/php different output depending on the machine, for example /c/Apps/php/php-7.2.11/php Then open the path specified in the php file.

For example, /c/Apps/php/php-7.2.11

Modify php.ini file can do

vi C:\Apps\php\php-7.2.11\php.ini

code C:\Apps\php\php-7.2.11\php.ini

 [Phar] ; http://php.net/phar.readonly phar.readonly = Off ; http://php.net/phar.require-hash phar.require_hash = Off 

Save

0
source

Source: https://habr.com/ru/post/1240134/


All Articles