How to fix php version for composer

My default php version is php 7.3, i have installed 8.0 and 8.1 as well.
Im using php version 8.1 with a website using below code and its working for me.
<FilesMatch .php$>
SetHandler “proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost”

But when i try to use PHP artisan command im getting this error:
PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies
require a PHP version “>= 8.1.0”. You are running 7.3.33-1+0~20211119.91+debian10~1.gbp618351. in
/path/vendor/composer/platform_check.php on line 24

I already used many commands below to fix it but i can’t.

composer config platform.php 8.1

/usr/bin/php8.1 /usr/local/bin/composer update

php8.1 /usr/local/bin/composer

composer config platform.php 8.1
“config”: {
“platform”: {
“php”: “8.1”
}
}
its been a day but i didn’t get any solution.

In “Edit User” → Cli settings change php version cli

And renew the ssh sessions

Or use:

/usr/bin/php8.1 /home/{user}/.composer/composer command here

I tried root@domain:/home/{user}# /usr/bin/php8.1 /home/{user}/.composer/composer
and error below
Could not open input file: /home/{ajmalsarim}/.composer/composer
In the cli PHP cli version only 8.0 showing

remove the { } and it should work fine

v-list-sys-php should list you available php versions

Yes i used without {} and the same error,
Could not open input file: /home/username/.composer/composer
with this command.
sudo update-alternatives --list php
showing
Screenshot_11
with
v-list-sys-php
showing
Screenshot_10
also i tried with php 8.0
root@domain:/home/user# /usr/bin/php8.0 /home/user/.composer/composer
still same error.
Could not open input file: /home/username/.composer/composer

and here root@domain:/usr/bin# ls
Screenshot_12
but when im going to my web directory, and run this command php artisan this is the error

root@domain:/home/user/web/domain.com# php artisan
Composer detected issues in your platform:

Your Composer dependencies require a PHP version “>= 8.1.0”. You are running 7.3.33-1+1+debian10~1.51.

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 8.1.0”. You are running 7.3.+1+debian10~1.g1. in /home/user/web/domain.com/vendor/composer/platform_check.php on line 24
I searched a lot but didn’t get any solution.

ls /etc/php/./*

I assume you are running on modphp
.

ls /etc/php/. /*
Screenshot_13

It looks like you are using modphp instead of php-fpm

Selection of multiple php versions doesn’t work well then:

Use

To convert to php-fpm

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.