How to Easily Manage PHP Versions in XAMPP on Windows

Sortxtech
3 min readNov 13, 2023

--

Navigating through different PHP versions in XAMPP can be daunting, especially for those new to development environments. This guide aims to demystify the process, making it accessible and straightforward for beginners. Whether you are a student, a hobbyist, or a new developer, this guide will help you efficiently switch between PHP versions on your Windows system.

Step 1: Create a Dedicated “xampp-versions” Folder

The first step in simplifying your PHP version management is to create a dedicated folder. This folder will be the central location for all the PHP versions you’ll install.

  1. Open the File Explorer on your Windows machine.
  2. Navigate to a preferred location, Like C: or D: drive.
  3. Right-click in the drive’s space, choose “New”, then select “Folder”.
  4. Name this new folder as “xampp-versions”. This name signifies its purpose but feel free to choose a name that suits you.

Step 2: Install the First PHP Version

Now, let’s start by installing your primary PHP version.

  1. Visit the official XAMPP website and download the version of XAMPP that includes the PHP version you want.
  2. Run the installer and when prompted, select the path “D:/xampp-versions/xampp” (or your chosen path) for installation.
  3. After the installation is complete, verify it by launching the XAMPP Control Panel. Click on “Shell” and then type php -v to see the installed PHP version.

Step 3: Adding New PHP Versions in XAMPP

As your requirements evolve, you may need to work with different PHP versions. Here’s how you can add more:

  1. Downloading the New Version: Start by downloading the desired PHP version from the XAMPP website.
  2. Renaming the Existing Installation: Before you install the new version, go to the “D:/xampp-versions” directory or where you create “xampp-versions” folder. Find the “xampp” folder and rename it to include its current PHP version, like “xampp-7.4”.
  3. Installing the New Version: Proceed with the installation of the new version in “D:/xampp-versions”. The installer will automatically create a new folder named “xampp” for this version.
  4. Verifying the New Installation: Open the XAMPP Control Panel, go to “Shell”, and type php -v to confirm the newly installed PHP version.

Step 4: Repeat for Additional PHP Versions

If you need more versions, just repeat Step 3 for each new PHP version you want to add:

  1. Ensure that the “xampp” folder is available for the new installation. If it’s in use, rename it to include its version number.
  2. Install the new PHP version, which will be placed in the “xampp” folder.
  3. Verify each installation by checking the PHP version through the XAMPP Control Panel.

Step 5: Switching Between PHP Versions

To switch between different PHP versions:

  1. In the “xampp-versions” directory, rename the folder of the currently active PHP version to include its version number.
  2. Rename the folder of the PHP version you wish to use to “xampp”.
  3. Verify the active PHP version by typing php -v in the XAMPP Control Panel's Shell.

Conclusion:

With this structured approach, you can now seamlessly switch between different PHP versions in XAMPP on your Windows machine. This method not only keeps your environment organized but also significantly simplifies the process of managing multiple PHP versions. Whether you’re working on different projects or testing across various versions, this system will ensure you have the flexibility and ease of access you need.

--

--