Managing multiple versions of PHP (or other things too)

One of the issues that I have faced is having and running multiple versions of PHP with ease.  I currently have 6 versions of PHP on my development machine.  Before, to invoke the non-primary version, I would have to call it by the full path.  I’ve tried making a common directory with symlinks and with shortcuts to the executables, but that never worked.

The issue with shortcuts is that Windows shortcuts are not, by their nature, executable.  This means that they will not be a valid target in the command prompt.  They showed promise because I could get the “start in”, or the folder that the program is based in.

That was important because with symlinks I would get the error that the DLL files were not found.  They were not in the common directory, because I could not keep 6 versions of the same files with the same names in the same folder.

I had to find another solution.  After a bit of Googling, I found some help on Stack Overflow.  Someone wanted to know how to have a shortcut to their Chrome exe file outside of the Chrome installation folder.  They had the same errors that I was getting, so I was able to use that solution.

All of my PHP installations are in C:\PHP.

A visual of the different PHP folders in C:\PHP
The folders in C:\PHP

As you can see, I have the non-thread-safe and thread-safe versions of 7.0, 7.1, and 7.2.

My goal was to be able to call my default PHP from the command line in the normal sense, and to call a default 7.2 (et al) version (which for me is non-thread-safe), and to call any of the six specifically.

The CurrentVersion folder is in my system Path.

I went with the .cmd extension, but .bat works as well.  In the end, I created 10 .cmd files, so I can address the 6 versions in 10 ways.

Lets take a look inside one of the specific .cmd files, php-7.2-nts.cmd

The six version specific ones all look like this one here.

For my ones where I specify version number but not threading, and for the default, I point to the other .cmd files.  Here is what is inside php-7.2.cmd

And php.cmd

Only 6 out of the 10 point to an actual exe file.  This is to save me some time when I update to the latest revisions.

Here is the way the pointing works out:

This is what it looks like in the command prompt: