Page 1 of 1

Switching php versions in XAMPP

PostPosted: 12. February 2019 14:20
by dCart
Is it possible to switch the PHP version in XAMPP?
I have several old projects working on max. php 5.6. I am working on new projects in php 7. I need both versions 5.6 and 7. Can I have them together in XAMPP, switching if necessary?

Re: Switching php versions in XAMPP

PostPosted: 12. February 2019 16:10
by Altrea
Technically it might be possible, but XAMPP does not provide any function to realize that.
The only environment XAMPP support to run two different PHP versions is to install two different XAMPP versions side by side. That way you can start either the php 7.x apache or the php 5.6 one.

Re: Switching php versions in XAMPP

PostPosted: 12. February 2019 16:20
by Nobbie
Here is a german posting where someone switches between PHP7 and PHP5: viewtopic.php?f=4&t=77836

If you dont understand german, translate it with http://www.deepl.com, a very sophisticated translator. Basically you have two different httpd-xampp.conf and use one of them due to the PHP version you need.

Actually there is a more sophisticated solution, instead of running PHP as a module you may install and run it in CGI Mode. There is a code snippet in httpd-xampp.conf how to accomplish it. At next install any desired PHP version, then create two different VirtualHosts, call them (for example) local.php5 and local.php7

In each VirtualHost you configure PHP as a module, in one choose PHP from the PHP5 folder, in the other choose PHP from the PHP7 folder. This does NOT work with PHP Module, because you cannot load more than one Module. But you can specify as many CGI versions as you like (therefore CGI instead of Module). You can choose the same DocumentRoot in booth VirtualHosts. Finally, if you did everything right, restart Apache, after you can run your script with PHP5 via http://local.php5/myscript.php and with PHP7 via http://local.php7/myscript.php. You even dont need to switch anything, everything depends on the URL and on the VirtualHost you choose.

Re: Switching php versions in XAMPP

PostPosted: 13. February 2019 17:35
by dCart
Nobbie thanks for the answer. Your solution is terribly complicated for me. Installing two versions of Xampp seems to be the best (for my skils).

Re: Switching php versions in XAMPP

PostPosted: 13. February 2019 18:17
by Altrea
If you want to install two xampp versions side by side there are some limitations.
You can only run the applications of a single xampp installation at a time, not both simultaniously.
You should not register any of the components as windows service because eaxh xampp versions expects the same service names for its applications.
You should use the zip versions instead of the installer versions because I am not sure if both Uninstaller would work.

Re: Switching php versions in XAMPP

PostPosted: 14. February 2019 16:45
by dCart
I have already installed it. One is in the xampp5 folder, the other in xampp7. I need php5 to disable xampp7 and run xampp5.

The switchover is needed once a week so I can click on it :)

Re: Switching php versions in XAMPP

PostPosted: 17. February 2019 15:42
by kamm
I'm using the solution posted here:
https://stackoverflow.com/a/49586592/429523

Doing it this way means you can run as many versions for PHP as you like with just one XAMPP installed.