I'm trying to install composer on my server (centos) but I keep getting this error :
The phar extension is missing.
Install it or recompile php without --disable-phar
ps:I am trying to install composer to work with laravel
Specifically for CentOS
Edit the file /etc/php.d/20-phar.ini and remove the ; character in front of the line:
extension=phar.so
Now the phar extension is enabled.
Composer is provided as a phar as that extension is a standard part of PHP 5.3 which is also the minimum required version for running Composer at all.
If you have a weird version of PHP 5.3+ without the phar extension you could also convert it to a zipball or tarball via online tools, unpack it to /usr/local/share/composer, and then symlink manually from /usr/local/bin/composer to /usr/local/share/composer/bin/composer. Assuming no other settings are preventing installation that should work as well.
PHAR is part of the PHP core since some years now. Its already installed as dynamic/shared extension, but probably and simply not activated in your case
Please check your php extension folder for a file "phar.so".
To enable the extension:
Go to your php.ini and enable extension = phar.so
Check the loaded PHP Extensions with php -m and look for "Phar"
Then re-run the Composer install
First, you need to get composer.phar by doing :
curl -sS https://getcomposer.org/installer | php
And move the composer.phar for using globally :
mv composer.phar /usr/local/bin/composer
Related
$ php composer.phar install
PHP's phar extension is missing. Composer requires it to run. Enable the extension or recompile php without --disable-phar then try again.
I trying the extension html2wiki (Unsupported) of mediawiki, where I need to install the composer to make it work.
My php version is: 7.0.13 and my question is
How to enable this extension https://pecl.php.net/package/phar
I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.
You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
In the end I solved this by getting my host to rebuild PHP with PDO support.
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.
I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.
You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
In the end I solved this by getting my host to rebuild PHP with PDO support.
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.
I have face this problem to install maatwebsite/excel on laravel 8. How can I fix it?
NB: PHP version running 8.
I solved the problem with
I just enable PHP gd extension from php.ini file
installing PHP package PhpSpreadsheet
The problem is about Laravel Excel requirements. It seems PhpSpreadsheet: ^1.15 is not installed. Here is the list of requirements for Laravel-Excel 3.1,
PHP: ^7.2\|^8.0
Laravel: ^5.8
PhpSpreadsheet: ^1.15
PHP extension php_zip enabled
PHP extension php_xml enabled
PHP extension php_gd2 enabled
PHP extension php_iconv enabled
PHP extension php_simplexml enabled
PHP extension php_xmlreader enabled
PHP extension php_zlib enabled
Make sure these are installed and enabled on your php.ini. Also make sure your php version on composer.json is set like this:
"require": {
"php": "^7.2|^8.0",
},
Instead of something like this "php": ">=7.2". Check this out for more information. Please let me know if it worked.
I just want share another answer related here. If you run on unix (linux), try install php-gd using command line. Try check other answer related to your system.
sudo apt-get update
sudo apt-get install php8.0-gd
related:
How to install PHP GD in Ubuntu
install php-gd ext on Debian
Issue with enabling GD in PHP
If you using windows. Use this command.
composer require maatwebsite/excel --ignore-platform-reqs
This problem happen only on php 8.x! perhaps on lastest php 7. The problem same as above and still failed even php-gd is active. When type
composer require maatwebsite/excel
the error still the same. When checking using
php -i
(basicly same as phpinfo in console). We can see php gd is active. This answer is not recommended at the moment. Fixed still on the way related to this issue.
related link:
https://github.com/Maatwebsite/Laravel-Excel/discussions/3191
PHP8 is supported, make sure to use 3.1.30 of the package as mention above. To see other issue, please read this link.
https://github.com/Maatwebsite/Laravel-Excel/issues/2936
I solved using
Enable zip and gd extension in php.ini
or install using sudo apt-get install php8.0-gd
sudo apt-get install php8.0-zip
use composer require maatwebsite/excel:^3.1 -W
-W is for with-all-dependencies
I have just used composer require maatwebsite/excel -W --ignore-platform-req=ext-zip and this has worked for me on linux ubuntu 20 with php 8.1
delete composer.lock (json)
then run below command
composer require phpoffice/phpspreadsheet
composer require maatwebsite/excel
it is working
I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.
You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
In the end I solved this by getting my host to rebuild PHP with PDO support.
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.