'Laravel - Composer detected issues in your platform after updating it

So i just updated composer using the command composer self-update --2, However, now my web application shows the error Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0".

I dont understand this because doing php -v gives me PHP 7.4.13

How can I fix this?



Solution 1:[1]

Your terminal user's PHP version may differ from the server's version.

You may have 7.4.13 on terminal while having a completely different PHP version in apache2 or whatever server you are using.

Use phpinfo(); in a PHP file and access it via browser to see the actual PHP version.

Solution 2:[2]

Here is quick solution that work for me

  1. In you project you can check the platform check file projec-path/vendor/composer/platform_check.php

    $issues = array();

after this Remove or comment the extra code

  1. Add the platform check option in the composer.json config section like this.

    "config": { "platform-check": false },

After that, you need to run

composer update

After the composer update platform_check.php will be deleted and project work fine.

Solution 3:[3]

Please run this command:

composer install --ignore-platform-reqs

Solution 4:[4]

I simply change the file platform_check.php which was showing the PHP_VERSION_ID >= 70400. change it to 70300 (This is for PHP >=7.3) This solve my issue.

Solution 5:[5]

I ran into this issue after installing a new version of PHP on a server using IIS. Not realizing that IIS didn't support verbs like UPDATE/PATCH out of the box, and these methods were being utilized by the website. When a route was accessed via PATCH for instance, the new version of PHP was not handling that, so it fell-back to the old version of PHP -- and that's when this error presented itself.

Resolving it was simply a matter of editing the Handler Mappings in IIS. I found the mapping that would point *.php files to my new version of PHP, and customized it so that it would support other verbs like PATCH

Solution 6:[6]

Problem is sometimes we forget to change the php version at server(platform) level, which is usually different from the dependency level or cli after an update or upgrade or even sometimes on a fresh installation.

  • For anyone using cpanel, ensure to update your php on the cpanel to the one used on the application or during development.

  • For anyone using apache, check your apache conf file for the project to make sure it has the same php version running in your cli i.e used by composer.

  • For anyone using nginx, check your nginx conf file for the project to make sure it has the same php version running in your cli i.e used by composer.

  • For anyone using valet check your current project' valet php version, to make sure its the same as the one used by composer, to change php version: valet use php[x.x]

Summary.

  • Check your server configuration to make sure it has the same php version required by your application.

Solution 7:[7]

inform required "require" version if desired or remove from composer.json

always put the ^ to indicate that the version can be equal or greater

then run composer update

in my case, it worked

{
    "require": {
        "php": "^7.4"
    },
    "autoload": {
        "psr-4": {
            "App\\": "App"
        }
    }
}

Solution 8:[8]

I have faced the same issue on my server. And it is mainly happened due to miss-match of php version between server version and your system version. I am using Nginx and checked on all my project configuration files, it uses php8.0 but on my terminal it shows php.8.1. Actually my application needs php8.0. The following steps resolved my issue.

To see all my running php versions

sudo update-alternatives --config php 

It shows the following page php all versions page

Selecting php8.0 for my application. Run the command to see Nginx scripts are ok

sudo nginx -t

Then reload the Nginx

sudo systemctl reload nginx

Finally go to your project directory and update or install your composer

composer update

It has been resolved my issue, I expect same will resolve yours.

Solution 9:[9]

Just update your version of PHP in cpanel. I ran into the same issues and this helped me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hache_raw
Solution 2 tread khuram
Solution 3 Muhammad Dyas Yaskur
Solution 4 Narayan P
Solution 5 Whipenstein
Solution 6 Adedoyin Akande
Solution 7 Suraj Rao
Solution 8
Solution 9 CodeLoop