Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel Composer sees wrong version of PHP

I’m trying to update Laravel from 9 to 10. I’ve followed the upgrade documentation and when I hit composer update, it gave me this error:

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

In the composer.json I already changed the php version on two places:

"require": {
    "php": "^8.1.0",
},

and

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"config": {

    "platform": {
        "php": "8.1.0"
    }
},

When I check my PHP with:

php -v

It shows that I’m using the correct version of PHP.

PHP 8.1.17 (cli) (built: Apr 11 2023 19:20:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.17, Copyright (c) Zend Technologies

I also cleared all the caches to Laravel and tried with:

composer dump-autoload

and I’m getting this error:

[ErrorException]
  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.28.

I’ve investigated even more and I found out when I try with this command:

composer -vvv about

The first line of the result looks like this:

Running 2.2.9 (2022-03-15 22:13:37) with PHP 8.0.28 on Linux / 3.10.0-1160.53.1.el7.x86_64

So, this means somehow Composer still runs PHP 8.0, instead of PHP 8.1.

How can I force Composer to use the proper version of PHP?

EDIT: Thank you guys for your suggestions but instead of rushing to mark the thread to be closed, the answer from ABJ was actually the real fix!

All those links which you posted and marked my thread as duplicated weren’t helpful at all because I already checked them.

Anyway, thank you ABJ for helping me out on this one. 🙂

>Solution :

Do you use php artisan serve?

when yes try /usr/bin/php artisan serve
this should start php 8.1.17

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading