Tutorial: PHP-VersionsSwitcher for Xampp

Gast

#1
if you work with the locale XAMPP-Server, maybe its good, if you can switch between different PHP-Versions. The Limiter for this Switch is your Xampp-Version. So its not possible to switch to a Version PHP 5.6.x, if your package needs a Version PHP 7.x. For this case, i use different Xampp-Installations and rename the xampp-folders, before i start the server

to the switch:
WHAT YOU NEED...
- a running Xampp-Installation on your locale PC, recommened the latest version from here -> https://www.apachefriends.org/de/index.html
- a different PHP-Version, maybe from here -> http://windows.php.net/download - i use for a example VC14 x86 Thread Safe for Windows
- the PHP-Switcher  from the attachement or from here -> https://code.google.com/archive/p/phpswitch/downloads

- Unpack this Switcher-Package into your locale Xampp-Folder, it will overwrite the existing Readme-Files, choose yes or no
- you need from the package in this zip the folder called "lib", a config.ini, the file php_switchbat and php_switch.php in the Xampp-Main-Folder
- open the config.ini with a simple editor and change there the yellow marked settings, the path to Xampp, the path to the php inside of xampp and the apacheService (older Xampp-Versions has Apache 2.2)

- rename the not used php-Folder and add there the php-Version, for example a folder with PHP 7.0.14 has the Name php_7.0.14
- dont rename the folder with name php - Xampp works only with the folder php (if you dont change the original settings), the switcher rename the folders

View in Windows-Explorer / Xampp-Folder


- you need inside of every php-versions-folder a file called PHP_VERSION. Content of this file is the versions number, like 7.0.14, not more
- you need a php.ini in every php-folder - in most cases, its enough, when you rename one of the php-ini-files in the php-folder, like php.ini-development to php.ini. if its not work, try a php.ini from a working-php-version



to use the Versions-Switch, be sure, that you stop a actual running apache server in your xampp-control-panel
to start the switch, start the file php-switch.bat ( i send this file to my desktop and change the icon (use the icon from xampp for that)


a DOS-Window starts, the Script reads the different php-folders and build a list. Select the PHP-Version, tip the number and close the window.
now you can start the apache server - if no red error come, everything is good and you can work with the different version





Last step: check the used PHP-Version in WB-Backend - Systeminfo (info-Button in the top-menu)