How to Install/Enable the PHP Phar Extension

How do I install / enable the PHP phar extension?

In the end I solved this by getting my host to rebuild PHP with PDO support.

How to install Phar on Ubuntu?

Try to run php -i|grep phar

If it shows result something like :

/etc/php/{version}/cli/conf.d/20-phar.ini,
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On

Everything should be correctly installed.

If it shows no result or no phar ini files mentioned / disabled then you just need to include the correct ini on your main php.ini and set the path to phar.sofiles.

or if you locate the phar.so file just add it on your main php.ini with

extension=phar.so

or

extension=path/to/your/phar.so

Update + extra to ensure ext dir location

It will be clearer if you grasp ini file location and ext dir used by your installation.

Try to do this:
php -i | grep ini

Then on the first/second line there will be your main ini file.

In my machine it shows this:
Loaded Configuration File => /etc/php/{version}/cli/php.ini

then do this command to make sure ext folder used or any extension declared on main ini:
cat /etc/php/{version}/cli/php.ini|grep ext

You could also do:

cat /etc/php/{version}/cli/php.ini|grep phar

To check phar related parameter on main ini file.

If those step show nothing, I think it will be simpler if you just reinstall your php package on your machine.

Install it or recompile php without --disable-phar (on windows)

If the php.ini files looks like below and with the command PHP -m doesn't show Phar, then you must re-install/ re-configure PHP as the Phar extension is bundled. After that , running again the php -m command to see if is enabled. Then follow the composer installation guide.

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

enable-phar shared Do I have to recompile PHP to Install Composer?

From what I understand reading about similar problems, that missing extension error should go away when you actually include that extension in your php.ini.

First of all, scan for an existing file phar.so - it should be around /usr/local/php54/lib or so.

Then check if there are any traces of configuration that just waits to be enabled in /etc/php54/conf.d. After that, and nothing was found that looks like being connected to phar, check the /etc/php54/php.ini in the [extension] section. There might be a line commented out that contains something like this: extension = phar.so. Activate it.

After that, php -m should give you a list of activated extentions including the phar one. There is no need to restart PHP on the command line, because there is no persistent process that needs a restart.

If this all fails, you probably have to accept "yes" as an answer to "Must I recompile?", but I doubt your installed PHP comes without the shared extensions .so files. And even if not, it's probably easier to install a missing package containing that extension.

Composer update: The requested PHP extension ext-http missing

in my case i'm using ubuntu, hope this solve the problem.

sudo apt install php-http

php.ini is missing/ help to install php

Make a copy of php.ini-development and rename it to php.ini (or choose php.ini-production if that suits your needs). These are sample configuration files you can base your own configuration on. Edit it to your liking afterwards.



Related Topics



Leave a reply



Submit