DEV Community

Cover image for Multiple PHP version on Windows 10
Thodoris Kouleris
Thodoris Kouleris

Posted on

Multiple PHP version on Windows 10

A very common problem that many PHP developers have is how to get multiple PHP version to run on the same computer. So, here is a solution.

Let's say that you already have installed PHP 7.4 on your computer, but you have to work on a project that needs PHP 8.2 to run. First head to https://windows.php.net/download/ where you can find the version that we are interested.

example 1

Find the version 8.2.8 and click on zip hyperlink to start downloading. Once the file is downloaded, create a folder in the path where your current PHP version is installed. For example, if you have installed your current PHP in C:\PHP\7.4 create a folder C:\PHP\8.2.8 and unzip the content of the zip file in that folder.

Now, you have both versions on your computer. Now, you have 2 options. Whether you will make the PHP8.2.8 your default version or using it every time you want to work with your new project.

Make PHP8.2.8 the default PHP
In order to make the new PHP the default system PHP version, you follow the next steps.
a. Open a command line
b. Type SystemPropertiesAdvanced
c. Go to Environment Variables

example 2

d. From the System variables, select Path and click Edit

example 3

e. Click new and add the path of your new PHP version. After that click, Move Up as many times you need so that path will be on top of the other PHP versions that you have.

example 4

f. Click OK to close the window, and that's it. You have PHP8.2.8 as the default system PHP version

example 5

Use it when you need it
The second option, if you don't want to make PHP8.2.8 your current version, is to use it only when you need it. So, let's say that you have a script that runs with older version. Open a command prompt and type the full path of the PHP version that you want to use, i.e. c\PHP\7.4\php myscript.php

Top comments (0)