Allow to use and switch between different versions of PHP for Xampp on Windows OS.
MIT License
Use and switch between different versions of PHP for Xampp on Windows OS.
Xampp is an easy to install Apache distribution containing MariaDB, PHP, and Perl. It has been around for more than 10 years – there is a huge community behind it. Currently, there are many other applications launched with more advantages. However, many people still love Xampp because of its ease of use. The problem is that quite a lot of people have not exploited the full power of Xampp.
Therefore, I have created 2 separate projects to take full advantage of what Xampp has to add to the features that many people desire to have in Xampp:
With this project, using and switching between different PHP versions for Xampp became easy. This will be useful for those who want to ensure their applications work smoothly on different PHP platforms or those who are researching PHP programming.
Note: Currently this project only supports Windows users.
Look at one of the following topics to learn more about Xampp PHP Switcher.
Xampp PHP Switcher takes full advantage of what's included in Xampp, nothing more needed. So, you just need following things:
Note: See here to know how to add Windows Path Environment Variable.
There are two installation methods, via Composer or manual download. It is recommended to use the method via Composer if you already have it installed.
(example: cd /D D:\)
.$ composer create-project jackiedo/xampp-php-switcher xphp "1.*"
(example: D:\xphp)
. Note: Should not place in C:\Program Files
or anywhere else that would require Administrator access for modifying configuration files.(run as Administrator)
.(example: cd /D D:\xphp)
.xphp install
and follow the required steps.Note: See here to know how to to open the command prompt as Administrator.
Currently, Xampp PHP Switcher does not have an automatic update mechanism, we have to do it manually step by step as follows:
settings.ini
in the folder where Xampp PHP Switcher application is installed to somewhere else.settings.ini
file into the Xampp PHP Switcher application folder back.After successfully installing Xampp PHP Switcher, by default you will have a built-in PHP version of your Xampp. In order to use other versions of PHP, we will proceed to add those builds to the repository. This will also be easily done. But you need to keep in mind the following requirements:
Execute the following command:
$ xphp info current
View the information in Architecture section and remember it.
Compatible items to download
Execute the xphp add
command:
$ xphp add "drive:\path\to\above\xampp-php-directory"
or more simply with the second syntax:
$ xphp add
And then provide the link above when requested.
Note: If you use the first syntax, you should put the path in the double quotes (") to avoid the errors of the effect of whitespaces.
And now we have many different versions of PHP to use. We can switch between versions with the xphp switch
command.
When we use the xphp add
command, Xampp PHP Switcher will do the following:
The process of standardize paths is done based on a file named "need_standardize.lst" located in the "src" folder of project directory. Currently, this file has supported the path standardization for PHP builds from versions 5.4 (Xampp 1.8.3) to 8.0 (Xampp 8.0.x).
Every time a new version of Xampp is released, this file will be checked and updated. You only need to copy the whole new content of this file and overwrite your existing file in your Xampp PHP Switcher directory. Or you proceed to update Xampp PHP Switcher according to the instructions here.
Because of a path to the Xampp PHP Switcher application directory has been added to the Windows Path Environment Variables during the installation process, now you can just open the terminal (no need to open in Administrator mode anymore)
anywhere and excute one of the following xphp
commands:
Syntax:
$ xphp help
Syntax:
$ xphp info current
Syntax:
$ xphp info [VERSION]
Example:
$ xphp info 5.6.40
Note: The VERSION parameter is optional. If you do not pass it to the command statement, you will also be asked to enter this information later.
Syntax:
$ xphp list
Syntax:
$ xphp remove [VERSION]
Example:
$ xphp remove 5.6.40
Syntax:
$ xphp add [PATH_TO_ANOTHER_XAMPP_PHP_DIRECTORY]
Example:
$ xphp add "D:\download\xampp-win32-5.5.19-0-VC11\php"
Syntax:
$ xphp switch [VERSION]
Example:
$ xphp switch 5.5.19
php.ini
editingOnce you have added the various PHP versions to your Xampp, they will be put in a repository located in a directory named "phpRepository" located in your Xampp directory. And they will have separate "php.ini" configuration files. If you need to edit the configuration for PHP, you must edit each "php.ini" file for each corresponding version in the repository.
MIT © Jackie Do