phpswitcher

phpswitch

I was searching for an easy way to switch php versions on my linux nginx development environment. And found a pretty good guide:
https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way

The solution had two downsides for me.

  • When switching the php version for the cli the server version wasn't switched.
  • There was not really a solution given for switching the server php but just another php version based on the port number.

So I took the usefull parts of that guide and combined everything in a little script. When running the script the cli version is switched and the configuration in sites-enabled is also changed according to the given php version. So in this way I don't have to remember the cli version and adjust my port in the browser, my url is clean without the port number and everything is done in just one command.

When you like to use the script it might be that you have to change some variables in the script. Like the path to you php installation and the path to your server configuration.

The command may take an argument, like: phpswitch 7.1
But you can also enter just the phpswitch command without an argument. In that case you will be presented with available php options on your system to select from.

https://gitlab.com/FlorisV/phpswitch