skip to Main Content

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

15

Answers


  1. 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:

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. 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 
    
    Login or Signup to reply.
  5. If @eril answer did not help you by disabling old PHP version

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

    use composer -vvv about to check that composer use 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
    
    Login or Signup to reply.
  6. If you are simply using git to version your Composer dependencies for a deployment, consider the --ignore-platform-reqs flag.

    • For more info, see Options at https://getcomposer.org/doc/03-cli.md#install-i

      composer update --dry-run --ignore-platform-reqs
      

      --ignore-platform-reqs: ignore all platform requirements (php, hhvm, lib-* and ext-*) and force the installation even if the local machine does not fulfill these. See also the platform config option.

    Login or Signup to reply.
  7. If you are operating on nginx server, It’s likely the php-fpm8.1 is not active.

    Try to:

    sudo systemctl status php-fpm8.1.service
    

    Depends on the status of the php-fpm version, you can act, and if it’s stopped, you may want to do the following:

    sudo systemctl enable php-fpm8.1.service
    sudo systemctl start php-fpm8.1.service
    

    Then double-check the status, and if it’s active. You’re good to go.

    Note: This applies to any php-fpm version, not just 8.1.

    Hope this help!

    Login or Signup to reply.
  8. if you use XAMPP, check that the PHP version of your XAMPP is the correct one (the same one you have on your computer). Otherwise, download and install the correct version of XAMPP

    Login or Signup to reply.
  9. Open your composer.json and check where the ‘require’ block says ‘php’. It has an expression that can put a constraint on the PHP version or version range that is allowed for all of your projects’ dependencies.

    A good value would be to use the one below. Change it and run composer update afterwards.

        "require": {
            "php": "^8.0|^8.1",
    

    Contrary to the composer.json which laravel 9 ships with:

        "require": {
            "php": "^8.0.2",
    

    (see laravel 9 composer.json in the official repository: https://github.com/laravel/framework/blob/9.x/composer.json)

    Login or Signup to reply.
  10. Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
    I faced the same problem.
    Just go to Cpanel.
    Then PHP Selector
    and finally, change PHP version
    enter image description here

    Login or Signup to reply.
  11. If you are in the process of upgrading Laravel versions and you switch to the version which requires PHP8 (8 or 9 cant remember)
    And you also switch PHP versions,
    you need to restart your

    php artisan serve
    
    Login or Signup to reply.
  12. If you install composer globally, just run composer global update. It will solve your problem.

    enter image description here

    Login or Signup to reply.
  13. in my case everything is fine

    • composer.json is fine
    • php 8.1 is installed
    • I am using nginx I restart nginx but I found that my configuration is wrong it looks like this
    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
    }
    
    

    so the correct configuration is

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }
    

    Hope this will help someone

    Login or Signup to reply.
  14. Don’t change any thing in your application. In your shard hosting, go to cPanel and find/search Multi PHP Manager. Select your domain or sub domain (whatever you are working with), from dropdown list select PHP 8.1 and apply.

    enter image description here

    Now find/search PHP Selector and for Current PHP Version select 8.1.

    enter image description here

    in the same window go to Extensions and enable pdo_mysql.

    enter image description here

    You are good to go.

    Login or Signup to reply.
  15. I had the exact issue.

    • I added the line phpversion() and found that the version was different from what was set for my apache.

    • I enabled the php8.1-fpm with this command:

      sudo a2enconf php8.1-fpm
      
    • After restarting Apache I got it working.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search