PHP version in webserver is different to PHP version in terminal

479 Views Asked by At

I'm using valet and have just created a fresh Laravel 10 project. One of my other projects requires PHP 7.3, so I switch between this and other versions using valet use [email protected]. For my new project, I switched to php 8.2 (verified this using php -v) but when I try to access the site in my browser, I get the following error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 7.3.33. in /Users/user/projects/my-project/vendor/composer/platform_check.php on line 24*

I'm not sure where it's getting that I'm running 7.3 from. composer -vvv gives 'Running 2.3.1 (2022-03-30 15:41:28) with PHP 8.2.12 on Darwin / 19.6.0' and php -v also gives 8.2?

I've tried:

rm ~/.config/valet/valet.sock
valet restart 

but this didn't fix the error I'm getting in my browser

1

There are 1 best solutions below

0
On

Check Valet Configuration: Verify that Valet is correctly configured to use PHP 8.2. You can check this by running valet use [email protected] in the terminal. If it's already set to PHP 8.2, try switching to a different version and then back to PHP 8.2.