When doing any development on my laptop I use the very useful MAMP to give me an xAMP (Apache, MySQL & PHP) environment.
I recently upgraded and found that the free version offers two versions of PHP: 7.4.33 and 8.2.0 which would be fine but my production server is still on 8.1 and so I needed to match that. I could have upgraded to MAMP Pro but £90 just to switch to PHP 8.1 seemed a bit much, although, I do appreciate that by doing so I would be supporting the developers.