skip to Main Content

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

"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?

1

Answers


  1. Do you use php artisan serve?

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

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