Switching php versions in XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Switching php versions in XAMPP

Postby dCart » 12. February 2019 14:20

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?
dCart
 
Posts: 11
Joined: 08. February 2019 12:27
Location: Poland
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Switching php versions in XAMPP

Postby Altrea » 12. February 2019 16:10

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.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Switching php versions in XAMPP

Postby Nobbie » 12. February 2019 16:20

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.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Switching php versions in XAMPP

Postby dCart » 13. February 2019 17:35

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).
dCart
 
Posts: 11
Joined: 08. February 2019 12:27
Location: Poland
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Switching php versions in XAMPP

Postby Altrea » 13. February 2019 18:17

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.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Switching php versions in XAMPP

Postby dCart » 14. February 2019 16:45

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 :)
dCart
 
Posts: 11
Joined: 08. February 2019 12:27
Location: Poland
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Switching php versions in XAMPP

Postby kamm » 17. February 2019 15:42

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.
kamm
 
Posts: 4
Joined: 20. November 2005 18:12


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 92 guests