pharphp-ini

Can't enable phar writing


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

Uncaught exception 'UnexpectedValueException' with message 'creating archive "..." disabled by the php.ini setting phar.readonly'

even if I turn to off the phar.readonly option in php.ini.

So how can I enable the creation of phar files ?


Solution

  • I had this same problem and pieced together from info on this thread, here's what I did in over-simplified explanation:

    1. in my PHP code that's generating this error, I added echo phpinfo(); (which displays a large table with all sort of PHP info) and in the first few rows verify the path of the php.ini file to make sure you're editing the correct php.ini.
    2. locate on the phpinfo() table where it says phar.readonly and note that it is On.
    3. open the php.ini file from step 1 and search for phar.readonly. Mine is on line 995 and reads ;phar.readonly = On
    4. Change this line to phar.readonly = Off. Be sure that there is no semi-colon at the beginning of the line.
    5. Restart your server
    6. Confirm that you're phar project is now working as expected, and/or search on the phpinfo()table again to see that the phar.readonly setting has changed.