skip to Main Content

I have uploaded my Laravel project to AWS hosting when I go to the IP address of EC2 instance it give me this error:

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

I check the PHP version and the current version 7.3. I don’t know what I actually need to do. First the version was 7.4, and then I downgraded it to 7.3.

18

Answers


  1. Open cPanel and type multiphp Manager. After that, select your desired domain and at the top right corner, change the PHP version to 7.3 or whatever you would like. Give it some time and your site will be up and running!

    See screenshot

    Login or Signup to reply.
  2. Problem:

    Your Composer checks the platform requirements (PHP version and loaded extensions) when the autoloader is loaded. If you run the application which does not meet the platform requirements, the application will exit with a message similar to this:

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

    Solution:

    You could use the easiest way: add --ignore-platform-reqs option to composer install/composer update to ignore all platform requirements.

    Login or Signup to reply.
  3. Follow this trick

    1. add this line in config object of composer.json file

      "platform-check": false

    2. run php artisan config:cache

    3. then run composer dump-autoload in terminal

    Login or Signup to reply.
  4. Ignoring is not the right option. You have to upgrade your PHP version. Take into account that by now, we already have PHP 8, so with version 7.2 you are far behind.

    Linux users

    Depending on your distributions, if you are using a Debian derivative like Ubuntu, use this link guide: Upgrade PHP version to PHP 7.4 on Ubuntu or just google for it and all will be fine.

    Windows users

    1. If you are using Windows, with Laragon, so all you have to do is
      download the PHP version that you want from
      https://www.php.net/downloads.php. Unzip the folder to
      c:/laragon/bin/php folder and then using Laragon GUI select another version in Menu/php.

    2. If you wish to upgrade the global Windows PHP version, you can
      use the Web Platform Installer. This for me
      was one the easiest way of doing it on Windows. For more
      information follow Install and Configure PHP.

    Login or Signup to reply.
  5. Actually, this was the only solution that worked for me:

    composer global update
    composer dump-autoload
    
    Login or Signup to reply.
  6. If you’re like me who had to downgrade the PHP version on your machine (Mac) due to a specific reason and when you run valet use php --force, you see the Composer global dependencies require PHP v7.3.0 or higher, then you’re in the right place. You can comment out the following three lines temporarily and that shall fix the issue for you when running valet use php --force again.

    Path: ~/.composer/vendor/composer/platform_check.php

    if (!(PHP_VERSION_ID >= 70300)) {
        $issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
    }
    

    Note: don’t forget to uncomment the relevant three lines after you switch to the latest version of PHP.

    Login or Signup to reply.
  7. This worked for me:

    sudo a2dismod php7.2
    sudo a2enmod php7.4
    sudo service apache2 restart
    

    Adjust php7.2 to your current module.

    Login or Signup to reply.
  8. So, having struggled with this very problem,

    PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.2.5". You are running 7.1.28

    for several hours, and finding that none of the above suggestions worked, I finally discovered that — at least on FreeBSD systems — the PHP module required by Apache is not installed by the main PHP package (e.g., "php74-7.4.19"), but instead by a different, module-specific package with its own versioning (e.g., "mod_php71-7.1.28").

    Executing php -v consults the php package; visiting phpinfo() consults the mod package.

    The clue to this is to execute pkg info | grep php and examine the results to see which packages you have installed. Obviously you have to adjust the above for the packaging system your system uses.

    Login or Signup to reply.
  9. Hashmat Waziri’s answer is right, but if anybody want to use your platform’s version, either Composer requires anything, he/she can set the code, depending on his/her system, into the composer.json file like:

    "config": {
        "platform": {
            "php": "7.1.0"
         }
    }
    
    Login or Signup to reply.
  10. The same problem downgrading from PHP 8.0 to 7.2 needed to run an older project.

    How I have fixed my issue:

    • Remove the broken dependency (installed previously with PHP 8)
    • Unlink the newest PHP version then link the older PHP version (I have used brew CLI to link/unlink $brew link [email protected], but I think you can use any PHP manager app to move to older version of PHP without any problem)
    • Then reinstall the dependency

    This fixed my problem and allow me to switch between different version without further problems, only requirement is use:

    composer global update
    

    after switching PHP version to refresh global dependencies.

    I have no clue about what caused the issue. Maybe something went funny during PHP version switch, but we weren’t able to put our finger to the cause of the trouble.

    P.S. Our problem was related to "laravel/install" package, uninstalling it required uninstall "laravel/valet" before, procedure isn’t changed though, simply we have to reinstall both packages on PHP 7.2.

    Login or Signup to reply.
  11. As mentioned in a comment under the original question, instead of just trying to hide the error or bypass it, It would be better to solve it completely to make sure the app performs the way it should. For that, we have to update the PHP version being used. I got this error in a cloud virtual_machine, so I had access to the terminal from where I installed the required version of PHP to the system.

    After that, I switched the active version of PHP from the older version to the newer version.

    To do this, I first ran,

    sudo a2dismod php7.2
    

    You will then see,

    Module php7.2 disabled. To activate the new configuration, you need to run: systemctl restart apache2

    As mentioned, run,

    sudo systemctl restart apache2

    Then run,

    sudo a2enmod php8.0

    This will enable the required version.Then run,

    sudo systemctl restart apache2

    A more detailed explanation is available here.

    Login or Signup to reply.
  12. I would reinforce the instruction not to blatantly ignore warnings. Would you ignore a warning on an electric fence telling there was a risk of death if you touched it?

    In my case I was trying to get an old application running, using PHP 7.2, so couldn’t just change the PHP version.

    My solution was fairly simple. Examine the composer.lock file to find which package requires the version of PHP reported in the warning. Find that package on packagist.org, look for a version of the package that matches your PHP version, and install it.

    E.g.,

    composer require <package>:<version>

    You may need to go through this a number of times. In my case I had to install packages that were wanting PHP 7.4 and those wanting PHP 7.3 before my application was happy.

    Login or Signup to reply.
  13. Those who are here after facing a similar issue on XAMPP (nothing to do with Laravel), I solved it by the following:

    Error shown to me:

    Composer detected issues in your platform: Your Composer dependencies require the following PHP extensions to be installed: mysqli, openssl

    • XAMPP was installed multiple times (without uninstalling the previous).
    • I uninstalled the one being shown in programs list.
    • restarted the PC.
    • then deleted all the directories of XAMPP.
    • restarted the PC.
    • installed XAMPP again.
    • — that’s all.
    Login or Signup to reply.
  14. Please use –ignore-platform-reqs with your composer command.

    –ignore-platform-reqs will ignore platform dependencies.

    composer install --ignore-platform-reqs
    

    or

    composer update --ignore-platform-reqs
    
    Login or Signup to reply.
  15. I encountered this issue on Aapanel on my VPS. I already had the latest version of PHP (PHP 8.1) but still, the error did not go every time I tried to run a composer command. I had many versions of PHP running, I tried all the suggested options but none worked. So I thought that maybe composer was seeing the wrong version of PHP and decided to uninstall lower versions(7.2,7.4) and that solved the error!

    Login or Signup to reply.
  16. it depends on how you check your PHP version, while there are different SAPIs in PHP, checking the version in Apache2 SAPI using phpinfo() is totally different from checking it from your terminal using php -v.

    Usually, when you install multiple versions, the OS does not override the old versions, for example, if you have PHP7.4, then when you install PHP7.3 you will have the two versions installed. however, your web server is not capable to manage the two versions at the same time.

    In your case, all that you need to fix this issue is to make sure that you are using the right SAPI in the right place.

    in your terminal check the version by using php -v, make sure that you are using the right version php7.3 in this case. and in your web server use phpinfo() to detect the current version, if it is not php7.3 you will need to enable it by the following command:

    a2enmod php7.3
    

    and if the error you are getting is in installing packages, you can install your package directly using the right bin

    php7.3 /usr/local/bin/composer require package_name
    
    Login or Signup to reply.
  17. so my solution to this issue was update php version on my mac

    1. install php by homebrew like this –> brew install php.
    2. update homebrew by –> brew update
    3. is to add installed php to paths
      • you should run these commands:

    then restart your terminal.

    Login or Signup to reply.
  18. Add below code in composer.json

    "config": {

        "platform-check": false,
        "platform": {
            "php": "7.1.0"
        }
    },
    

    and run command composer dump-autoload

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