Hi all, Tomorrow I will start a new job as a php developer. In my experience my Dev stack involved vagrant, so I can develop on the same environment as prod. The company I will work, told me they use a windows (don’t ask why, I’ll figure it out tomorrow) vm with apache and php, with some shared folder (the concept is like vagrant, but “manually”).

They told me they implemented this structure because they can easily switch between php version.

My question is, is there a better way to do this? How do you test your software in multiple php versions?

The host os is windows, by the way.
We have a mixture of developers using Windows, Linux and Chrome OS. All running their stack on devilbox which is great way to get up and running with docker.

Multiple versions of php, Apache and nginx plus many other bits which can be enabled through a simple config file.
Docker Desktop + WSL2.

Can easily have a different container for each version of PHP.
Can I use it even if is not used in prod? I mean… Docker..
I like more WSL1 because even if is a little “slower”(imperceivable for me) it shares directly the filesystem and the network.

You can then install all the major PHP fpm versions like 8, 7.4, etc on your WSL instance, and from the Nginx config file you can configure multiple PHP version with the same project with different server names like php8.dev.yourproject.com php7-4.dev.yourproject.com, then you can run the same project with multiple PHP versions without switching anything.

How much freedom do you have to use what you like? Spinning a linux VM might be a good option if your company policy allows. Changing php version should be not much more than disabling the php module in apache and enabling another one.

So as to answer your question, I use a VM for testing purposes, and for switching php versions, I use apache’s ability to load different modules as needed. If you’re willing to use Debian or openSUSE, you can simply use the a2enmod/s2dismod commands.

source