While trying to use Composer to create a Symfony 4 project I got the following error:
steve#laptop ~ $ php composer.phar create-project symfony/skeleton my-proj
Installing symfony/skeleton (v4.0.0)
- Installing symfony/skeleton (v4.0.0): Loading from cache
Created project in my-proj
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- symfony/framework-bundle v4.0.1 requires ext-xml * -> the requested PHP extension xml is missing from your system.
- symfony/framework-bundle v4.0.0 requires ext-xml * -> the requested PHP extension xml is missing from your system.
- Installation request for symfony/framework-bundle ^4.0 -> satisfiable by symfony/framework-bundle[v4.0.0, v4.0.1].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
steve#laptop ~ $ php --ini
steve#laptop ~ $ php --version
PHP 7.2.0-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec 7 2017 20:14:31) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.2.0-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies
steve#laptop ~ $ sudo apt-get install php-xml
[sudo] password for steve:
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-xml is already the newest version (1:7.1+55+ubuntu16.04.1+deb.sury.org+1).
0 to upgrade, 0 to newly install, 0 to remove and 253 not to upgrade.
I did search in php.ini for ext-xml to see if I could uncomment it in order to enable it but I did not find any mention of ext-xml. I have not searched anywhere else because I am very unsure about what I am doing.
Any help would be very much appreciated, Steve
It looks like you're using ubuntu 16.04 with the ondrej/php ppa to get the latest version of php. In this case, the package names need to match the version of php you're using:
apt-get install php7.2-xml
You can see the different versions available with something like this:
apt-cache search php | grep xml
Depending on your configuration, you may need to prefix the installation command with sudo.
Try out
Step 1:
sudo apt install php-xml
Step 2:
Restart apache
Resolved my issue
On Amazon linux or Centos
sudo yum install php-xml
if you're running on nginx restarting is not needed
Remove all versions for php and install only one version
Related
I have a problem with a Symfony project that I have to work on, when I try a 'composer install' on my bash, I have this message :
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for ocramius/package-versions 1.5.1 -> satisfiable by ocramius/package-versions[1.5.1].
- ocramius/package-versions 1.5.1 requires php ^7.3.0 -> your PHP version (7.2.24) does not satisfy that requirement.
Problem 2
- ocramius/package-versions 1.5.1 requires php ^7.3.0 -> your PHP version (7.2.24) does not satisfy that requirement.
- ocramius/proxy-manager 2.2.3 requires ocramius/package-versions ^1.1.3 -> satisfiable by ocramius/package-versions[1.5.1].
- Installation request for ocramius/proxy-manager 2.2.3 -> satisfiable by ocramius/proxy-manager[2.2.3].
It seems obvious that my php version isn't up-to-date and I have to upgrade to the 7.3.0 version minimum, but when I make an 'apt search php', the latest version that I have is 7.2 and the 'php -v' command return this message :
PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright (c) 1999-2018, by Zend Technologies
Did anyone how can I force the upgrade of my php version ? It will be very helpfull.
Thanks & have a great day
You can upgrade your PHP version, depending of your OS but you can also "fix" the PHP version in your project with composer.json. In your composer.json you may have a "config" key, add "platform" with your PHP version, 7.2 in your case:
{
"name": "xxxx",
...
"config": {
"platform": {
"php": "7.3"
}
},
...
}
It's recommended to fix the version that you have in production :
Official doc: https://getcomposer.org/doc/06-config.md#platform
Check also this blog article : https://blog.martinhujer.cz/17-tips-for-using-composer-efficiently/ (Tip #15)
To update PHP version to 7.3 on linux, here is steps :
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt -y install php7.3
If you need to install additional packages:
sudo apt-get install -y php7.3-{bcmath,bz2,intl,gd,mbstring,mysql,zip}
I'm trying to install Laravel using composer for the first time.
Following the documentation on https://laravel.com/docs/5.1, I tried doing it with the command sudo composer global require "laravel/installer".
The output I got is pasted below:
Changed current directory to /home/israel/.composer
Using version ^2.0 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/installer v2.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- laravel/installer v2.0.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- Installation request for laravel/installer ^2.0 -> satisfiable by laravel/installer[v2.0.0, v2.0.1].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/15-xml.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-curl.ini
- /etc/php/7.2/cli/conf.d/20-dom.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-mbstring.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-simplexml.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
- /etc/php/7.2/cli/conf.d/20-wddx.ini
- /etc/php/7.2/cli/conf.d/20-xmlreader.ini
- /etc/php/7.2/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.2/cli/conf.d/20-xsl.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, deleting ./composer.json.
Does this mean PHP isn't installed?
Just run sudo apt-get install php7.2-zip && sudo apt-get install php-zip. After which you would run the command (sudo composer global require "laravel/installer") again.
It should work just fine.
It actually did. :)
If you try
sudo apt-get install php7.2-zip
and you run into the error:
sudo: apt-get: command not found
Then, try it with homebrew instead:
brew install php
This worked for me. Hopefully it saves someone a few minutes of extra head scratching :) Happy coding!
Have a look at the Laravel requirements:
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
Do you meet them? Your Error message states, that your environment does not meet the PHP version and extensions, so you have to install them first.
Once you have installed the correct PHP version and the corresponding extensions, composer will be able to install laravel as desired.
Hope this helps! :)
This question already has answers here:
install ext-zip for Mac
(12 answers)
Closed last month.
I have seen this question answered on other posts here, but none of the answers work for me. Mostly because I'm trying to install laravel locally on my mac and the answers are for Linux environments and brew claims it doesn't have this extension. Here is my output when I run the composer command:
$ composer global require "laravel/installer"
Changed current directory to /Users/frankaddelia/.composer
Using version ^2.0 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/installer v2.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- laravel/installer v2.0.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- Installation request for laravel/installer ^2.0 -> satisfiable by laravel/installer[v2.0.0, v2.0.1].
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php5/lib/php.ini
- /usr/local/php5/php.d/10-extension_dir.ini
- /usr/local/php5/php.d/20-extension-opcache.ini
- /usr/local/php5/php.d/40-curl.ini
- /usr/local/php5/php.d/40-openssl.ini
- /usr/local/php5/php.d/50-extension-apcu.ini
- /usr/local/php5/php.d/50-extension-curl.ini
- /usr/local/php5/php.d/50-extension-gmp.ini
- /usr/local/php5/php.d/50-extension-igbinary.ini
- /usr/local/php5/php.d/50-extension-imap.ini
- /usr/local/php5/php.d/50-extension-intl.ini
- /usr/local/php5/php.d/50-extension-mcrypt.ini
- /usr/local/php5/php.d/50-extension-mongodb.ini
- /usr/local/php5/php.d/50-extension-mssql.ini
- /usr/local/php5/php.d/50-extension-pdo_pgsql.ini
- /usr/local/php5/php.d/50-extension-pgsql.ini
- /usr/local/php5/php.d/50-extension-propro.ini
- /usr/local/php5/php.d/50-extension-raphf.ini
- /usr/local/php5/php.d/50-extension-readline.ini
- /usr/local/php5/php.d/50-extension-redis.ini
- /usr/local/php5/php.d/50-extension-xsl.ini
- /usr/local/php5/php.d/99-liip-developer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
I try to install the missing extension with brew, but I get this error like so:
$ brew install php7.2-zip
Updating Homebrew...
Error: No available formula with the name "php7.2-zip"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
By the way, here is my php version:
php -v
PHP 7.3.0beta2 (cli) (built: Aug 21 2018 08:13:27) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0beta2, Copyright (c) 1999-2018, by Zend Technologies
I can't seem to figure out how to get this missing extension and haven't found a solution that works for me after a few hours of googling. I just reformatted my mac dealing with a different server environment issue, so I don't mind reinstalling again and starting over, but I want to try to fix the issue without doing so if possible. Any help is greatly appreciated!
* EDIT *
Output for php -m
$ php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imap
intl
json
libxml
mbstring
mcrypt
mongodb
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
propro
raphf
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
At first you have to install php extension zip. To do the installation just run the following
sudo apt-get install php7.2-zip && sudo apt-get install php-zip
Now you can try again to install laravel installer using composer
Why does the composer error show that you are using php5?
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php5/lib/php.ini
- /usr/local/php5/php.d/10-extension_dir.ini
- /usr/local/php5/php.d/20-extension-opcache.ini
- /usr/local/php5/php.d/40-curl.ini
- /usr/local/php5/php.d/40-openssl.ini
- /usr/local/php5/php.d/50-extension-apcu.ini
- /usr/local/php5/php.d/50-extension-curl.ini
- /usr/local/php5/php.d/50-extension-gmp.ini
- /usr/local/php5/php.d/50-extension-igbinary.ini
- /usr/local/php5/php.d/50-extension-imap.ini
- /usr/local/php5/php.d/50-extension-intl.ini
- /usr/local/php5/php.d/50-extension-mcrypt.ini
- /usr/local/php5/php.d/50-extension-mongodb.ini
- /usr/local/php5/php.d/50-extension-mssql.ini
- /usr/local/php5/php.d/50-extension-pdo_pgsql.ini
- /usr/local/php5/php.d/50-extension-pgsql.ini
- /usr/local/php5/php.d/50-extension-propro.ini
- /usr/local/php5/php.d/50-extension-raphf.ini
- /usr/local/php5/php.d/50-extension-readline.ini
- /usr/local/php5/php.d/50-extension-redis.ini
- /usr/local/php5/php.d/50-extension-xsl.ini
- /usr/local/php5/php.d/99-liip-developer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Are you using php5 before? If yes, I think you can try uninstall the php5 first.
Run this on terminal:
sudo apt-get install php7.2-zip && sudo apt-get install php-zip.
After which you would run the command (sudo composer global require "laravel/installer")
Greetings fellow developers,
I am trying to use composer for a PHP project of mine on a development server I recently booted up and for some reason I am unable to. I successfully installed composer, however, when I try to run the require command I get the following error:
root#webserver:/var/mypersonal/index# composer require php-amqplib/php-amqplib
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll' - /usr/lib/php/20151012/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^2.6 for php-amqplib/php-amqplib
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- php-amqplib/php-amqplib v2.6.3 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.0 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- Installation request for php-amqplib/php-amqplib ^2.6 -> satisfiable by php-amqplib/php-amqplib[v2.6.0, v2.6.1, v2.6.2, v2.6.3].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, deleting ./composer.json.
I'm assuming it's something to do with the PHP warning I recieve right when running the composer require command but no google search results lead me to the correct direction.
Additionally, I have provided my /etc/php/7.0/cli/php.ini file incase of an error in that file.
https://gist.github.com/anonymous/bc5bac59d684cbf575cef931ef36daf6 (I couldn't include the file in this post due to the character limit on posts.)
Thank you.
You can use function get_loaded_extensions to see if bcmath modul is loaded. Or in terminal php -m or php -m | grep name_of_the_modul
You can install it depending on what OS you are using:
Ubuntu
sudo apt install php7.0-bcmath
CentOS
yum install bcmath
PHP 7.2
Debian - jessie
apt-get update
apt-get install php7.2-bcmath
work like a charm :)
For any version in php Centos use
This solution worked for me
yum install php-bcmath
PHP will take the default version installed in the machine, search for that package and install it.
Delete the file composer.lock file if that is already created and then run again,
composer install
If you run
composer update
it will update whatever default packages are installed in composer.json which might create problem for you.
In Ubuntu 20.04
For php 7.4.3, sudo apt install php7.4-bcmath
For PHP 7.1, the following worked for me:
sudo apt install php7.1-bcmath
If you are using Docker:
bcmath can be installed by running this command inside a container: docker-php-ext-install bcmath
check your php version by type: php --version
you will see something like this:
PHP 7.2.9-1+ubuntu16.04.1 ....
then sudo apt install phpX.X-bcmath where X.X is php version, so for this ^ example it will be sudo apt install php7.2-bcmath
after this check if module existed or not by type php -m | grep bcmath
php 7.2 if you have other version just change it accordingly
For CentOS
sudo yum install php72-bcmath
For Ubuntu
sudo apt install php7.0-bcmath
Run this command, hope it will works
sudo apt-get install php-bcmath
hope this will fix the problem.
sudo apt install php-bcmath
For this problem we should use sudo apt install php-bcmath
Strange thing here
Some month ago I have installed all PHP version in the same manner. In here are the 4 identically configured version of php: 5.6, 7.0, 7.1, 7.2, with the same extensions ( when this was made possible ).
The strange thing was that bcmath is present for all php version excluding 7.1.
In the solution search I arrive here in this question, where the logic's things was confirmed installing bcmath, but in my Linode Debian 9 server the command
apt install php7.1-bcmath
doesn't work, with 3 error messages;
E: Impossible to find the package php7.1-bcmath
E: Impossible to find some package with glob "php7.1-bcmath"
E: Impossible to find a package with the regular expression "php7.1-bcmath"
The goals no meet with any combination of tips and trick, refreshing apt cache, change Debian's mirrored server, installing yum, so on...
After some tentatives I had an illumination: modificating of /etc/apt/sources.list enabling the default Linode repository, then after an apt update (with no solution in the immediate), I have restored the /etc/apt/sources.list commenting out the Linode mirror sources again. Magically, after the new apt update the command now are working.
By this I confirm: apt install php7.1-bcmath is the right command, but your Debian can need a kick in the ass
Install with this command, thats work for me
apt-get install php-bcmath
I tried below package and it worked in Php version 5.6
yum install php56w-bcmath
For those who have already tried installing bc-math and still composer is giving errors.
Try this command
rm composer.lock
It will definitely work
I just wondering how composer check which php to use when check for requirements. I use MacOS and in terminal type:
composer require phpunit/phpunit
the result is something like:
Problem 1
- phpunit/phpunit 5.0.4 requires php >=5.6 -> your PHP version (5.5.27) or "config.platform.php" value does not satisfy that requirement....
When I check php version:
php -v
The result is:
PHP 5.6.10 (cli) (built: Jun 12 2015 14:08:56) Copyright (c) 1997-2015
The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend
Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
Which is:
which php
php: aliased to /Applications/MAMP/bin/php/php5.6.10/bin/php
Can someone explain this. Thanks in advance!
Composer can tell you what version of PHP it's running on, if you specify debug verbosity -vvv.
I like to run it with the about command, since the output is relatively short.
composer -vvv about
Example output:
...
Running 1.8.5 (2019-04-09 17:46:47) with PHP 7.3.5 on Darwin / 18.6.0
...
Edit:
This has gotten more interest than I expected, so here's a version with cleaner output:
composer -vvv about 2>&1 | grep "PHP"
On MacOs X the default installation of php resides in /usr/bin. If you upgrade your php it will most likely be installed somewhere else (like /usr/local/php5), or if you use MAMP or something else it will be elsewhere. Just make sure that the first occurrence of php when traversing your PATH is the same as the version your webserver is using. (like have /usr/local/php5/bin before /usr/bin in your PATH). That will solve your problem.
If you used a package install method, such as apt-get on Ubuntu, chances are that the executable will include a "shebang" pointing to the specific php that should be used to run that specific composer file.
When using the command composer the cli will first resolve which binary to use. By running which composer you can find what binary that is.
$ which composer
/usr/bin/composer
Once you know that, you can open the file, for instance using vim: vim /usr/bin/composer (generally it takes super user access to modify binaries so you shouldn't be able to mess composer up doing that).
On the first line of the composer binary should be a shebang, possibly looking like #!/usr/bin/php that would instruct the composer executable on how it should run.
You can then call that php binary directly to verify its version:
/usr/bin/php -v
( sharing this here because I was looking for it an landed here but nothing satisfied me so I will share for those who land here for the same reason: )
With the following command you can check which composer packages depend on a specific php version:
composer depends php | grep 8.1
will output something like:
symfony/console v6.1.4 requires php (>=8.1)
symfony/css-selector v6.1.3 requires php (>=8.1)
symfony/deprecation-contracts v3.1.1 requires php (>=8.1)
symfony/error-handler v6.1.3 requires php (>=8.1)
symfony/event-dispatcher v6.1.0 requires php (>=8.1)
symfony/event-dispatcher-contracts v3.1.1 requires php (>=8.1)
symfony/finder v6.1.3 requires php (>=8.1)
symfony/http-foundation v6.1.4 requires php (>=8.1)
symfony/http-kernel v6.1.4 requires php (>=8.1)
symfony/mailer v6.1.4 requires php (>=8.1)
symfony/mime v6.1.4 requires php (>=8.1)
symfony/process v6.1.3 requires php (>=8.1)
symfony/routing v6.1.3 requires php (>=8.1)
symfony/service-contracts v3.1.1 requires php (>=8.1)
symfony/string v6.1.4 requires php (>=8.1)
symfony/translation v6.1.4 requires php (>=8.1)
symfony/translation-contracts v3.1.1 requires php (>=8.1)
symfony/var-dumper v6.1.3 requires php (>=8.1)