We are running XAMPP with PHP 7.0 because our new products requires PHP 7.
But there are old project which use functions like mysql_connect
, etc. Those are removed in PHP 7.0.
So is there way to easily change PHP versions in XAMPP.
Note : Please don't suggest to upgrade old project to compatible with new versions because I am not in a position to do it because that decisions I can't get as a developer (just an employee).
This is probably the least technical answer to the question, but it's also the easiest to accomplish.
If you have two drives such as C: and D: you can install a separate instance of XAMPP on both drives with different php versions. This took me less than 10 mins to do and is least error prone.
I just create two desktop shortcuts to both xampp-control.exe and name the shortcuts after their php version. I hope this helps someone like me that prefers a very quick and dirty solution.
You can have two different versions of XAMPP.
I use Uniserver.
It has this feature built in.
http://www.uniformserver.com/
It's that simple.
It even runs off a flash drive. Has cron emulation, support for perl, mariaDB, a couple versions of Mysql, filezilla server and a few other things.
Yes you can. I assume you have a xampp already installed. So,
That's how I am working with multiple xampp installed
Run an older PHP version for only the directory of your old project: This will serve the purpose most of the time, you may have one or two old projects that you intend to run with older PHP version. Just configure xampp to run older PHP version only for those project directories.
Run an older PHP version on a separate port of xampp: Sometimes you may be upgrading and old project to latest PHP version when you need to run the same project on new and older PHP version back and forth. Then you can set an older PHP version on a different port (say 8056) so when you go to
http://localhost/any_project/
xampp runs PHP 7 and when you go tohttp://localhost:8056/any_project/
xampp runs PHP 5.6.Step 1: Download PHP
So you have PHP 7 running under xampp, you want to add an older PHP version to it, say PHP 5.6. Download the nts (Non Thread Safe) version of PHP zip archive from here and extract the files under
c:\xampp\php56
. The thread safe version does not include php-cgi.exe.Step 2: Configure
php.ini
Open
c:\xampp\php56\php.ini
file in notepad. If the file does not exist copyphp.ini-development
tophp.ini
and open it in notepad. Then uncomment the following line:Step 3: Configure apache
Open xampp control panel, click config button for apache, and click
Apache (httpd-xampp.conf)
. A text file will open up put the following settings at the bottom of the file:Note: You can add more versions of PHP to your xampp installation following step 1 to 3 if you want.
Step 4 (option 1): [Add Directories to run specific PHP version]
Now you can set directories that will run in PHP 5.6. Just add the following at the bottom of the config file to set directories.
Step 4 (option 2): [Run older PHP version on a separate port]
Now to to set PHP v5.6 to port 8056 add the following code to the bottom of the config file.
Finish: Save and Restart Apache
Save and close the config file, Restart apache from xampp control panel. If you went for option 2 you can see the additional port(8056) listed in your xampp control panel.
Maybe a bit late, but I am using a batch to rename the PHP folders (a slightly modified version of the phpswitch I found years ago).
You copy the different folders into your XAMPP installation. Each PHP folder (except for the active one) receives the version number as a suffix (eg. php_5.6.32). In ALL PHP folders, a file (PHP_VERSION) is created, which contains only the respective version number, so the Script can grab this information. But that's all described in the README.
Since PHP7 the httpd-xampp.conf loads the php7ts.dll instead of the php5ts.dll. So i had to extend the script (PHPSwitch.php) to rename these config-files too by following the same approach.