Your Composer dependencies require a PHP version ">= 8.1.0"

Viewed 18052

I am getting this error with Laravel 9, I have PHP 8.1.7 installed

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".

I can see other have asked the question, bit non of the solutions seem to be working

5 Answers

I had the same problem and it was because I configured a version of PHP 8.1 on the command-line while I kept the PHP module at 8.0.

So PHP_VERSION_ID gave me 80020, while php -v gave me 8.1.7.

It reminded me to reconfigure the PHP Module to PHP version 8.1:

sudo a2dismod php8.0

sudo a2enmod php8.1

sudo systemctl restart apache2

And then everything worked like intended.

Reference:

TIPS

Add this lines in composer.json file:

{
    "config": {

        "platform-check": false
    }
}

Or set the version:

{
    "config": {

        "platform": {
            "php": "7.1.0"
        }
    }
}

And run composer dump-autoload

Your Composer dependencies require a PHP version ">= 8.1.0"

I had this same issue while I downgraded my php to v7.4 from 8.1. I somehow messed up with php7.4-fpm mod. However, when I again tried to upgrade my php v8.1 composer started to complain about that error. I simply removed my both php versions that's 7.4 and 8.1 and re-installed only 8.1, which fixed my issue.

To remove, here are the steps I followed....

sudo apt-get purge php8.*
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.1

and then finally,

sudo service apache2 restart 

If @eril answer did not help you by disabling old PHP version

sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2

also check composer using a correct version of PHP

composer -vvv about 2>&1 | grep "PHP"

if composer about already shows a correct version of PHP,then check to see the real PHP binary path that composer is using by putting PHP_BINARY inside vendor/composer/platform_check.php like this:

if (!(PHP_VERSION_ID >= 80100)) {
    $issues[] = 'You are running ' . PHP_VERSION . ' located at: ' . PHP_BINARY;
}

in my case, an old version of php-fpm was enabled.

a2disconf php8.0-fpm 
a2enconf php8.1-fpm 
sudo systemctl restart apache2

It's just until I find how to solve it but it's working So that's what i've done :

  • download php 8.1.9 (nts)
  • extract it in bin/php/ (i use Laragon)
  • move php 7.14.19 in a new folder(just for preventing)
  • and rename my php 8 folder to php 7 folder name
  • it's still working

Just find the php folder of your server

Related