The Problem

I'm getting this error: "- Root composer.json requires php ^7.1.3 but your php version (8.1.8) does not satisfy that requirement." for many packages."


The Configuration

OS: Windows 11

VM: Laravel Homestead

PHP Version: 8.1


What I Tried

So I ignored the requirements with composer install --ignore-platform-reqs but I get this error: "Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255"

It did run a partial update of the Composer Plugins, but not all.


So I destroy the vm and reprovisioned, same errors.


The Solution

Simply SSH into Homestead (vagrant ssh) then php73 which - if you aren't aware - switches the PHP version of the server. Then re-rerun composer update and composer install in that order.


The issue for me is that despite specifying my PHP version for this site in my Homestead.yaml file, it's ignored. I have no idea why. So I have to manually switch the PHP version from 8.1 to 7.3.