## jackiedo /xampp-php-switcher

Allow to use and switch between different versions of PHP for Xampp on Windows OS.

##### Details

Source

Issues

15

0

2

3

1

Type:project

1.0.1 2020-01-24 07:55 UTC

This package is auto-updated.

Last update: 2021-05-24 10:53:45 UTC

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:

• One is the feature that allows the use of different versions of PHP (this project).
• One is the vhosts management feature, comes with self-signed SSL certificates (see here).

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.

# Features of this project

• Install and manage various PHP builds for a single Xampp version.
• Switch between different versions of PHP quickly and easily.

# Overview

## Compatibility

Xampp PHP Switcher is compatible with all Xampp versions using PHP 5.4 or higher.

## Requirement

Xampp PHP Switcher takes full advantage of what's included in Xampp, nothing more needed. So, you just need following things:

• Xampp installed successfully (this project does not yet support the portable Xampp version).
• Added the path to PHP directory of Xampp into Windows Path Environment Variable.
• (Optional) Installed Composer.

Note: See here to know how to add Windows Path Environment Variable.

## Installation

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.

#### Via Composer Create-Project

• Open a terminal.
• Navigate to the directory you want to install Xampp PHP Switcher into (example: cd /D D:\).
• Run composer create-project command:
$composer create-project jackiedo/xampp-php-switcher xphp "1.*"  #### Via Manual Download • Download the latest release • Extract the archive to a shared location (example: D:\xphp). Note: Should not place in C:\Program Files or anywhere else that would require Administrator access for modifying configuration files. • Open a terminal in Administrator mode (run as Administrator). • Navigate to the directory you have placed Xampp PHP Switcher (example: cd /D D:\xphp). • Execute the command xphp install and follow the required steps. • Exit terminal (to remove temporary environment variables). Note: See here to know how to to open the command prompt as Administrator. ## Add other PHP versions to your Xampp #### Important notes 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: • Only add builds downloaded from the Xampp official website, or builds that have been added to the Xampp PHP Switcher repository. • Only builds with the same architecture (32 or 64 bit runtime) may be added to the current build. We perform each of the following steps: #### Check architectural information of the current build Execute the following command: $ xphp info current


View the information in Architecture section and remember it.

• After downloading, extract it to somewhere on our computer and note the path to the PHP directory inside the newly extracted Xampp directory.

Execute the xphp add command:

$xphp add "drive:\path\to\above\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.

#### Behind the process of adding PHP build

When we use the xphp add command, Xampp PHP Switcher will do the following:

• Copy the entire directory containing the PHP build into the repository.
• Conduct standardization of the paths in some files of new PHP build so that it is compatible with the path to our Xampp directory.
• Create a file containing the PHP build archive information (with name ".storage") and place it into the directory of the build.

#### Update the process of adding PHP builds in the future

The process of standardize paths is done based on a file named "need_standardize.lst" located in the project directory. Currently, this file has supported the path standardization for PHP builds from versions 5.4 (Xampp 1.8.3) to 7.4 (Xampp 7.4.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 can download the project source code here and extract (overwrite) to your Xampp PHP Switcher directory.

## Usage

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  #### Display information of current PHP version Syntax: $ xphp info current


#### Display information of existing PHP version in repository

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  #### Remove an existing PHP version outof repository Syntax: $ xphp remove [VERSION]


Example:

$xphp remove 5.6.40  #### Add one PHP version to repository Syntax: $ xphp add [PATH_TO_PHP_DIRECTORY]


Example:

$xphp add "D:\download\xampp-win32-5.5.19-0-VC11\php"  #### Switch to specific PHP version to use Syntax: $ xphp switch [VERSION]


Example:

\$ xphp switch 5.5.19