DEV Community

Cover image for How to install latest PHP on Windows 11
Farhan Helmy
Farhan Helmy

Posted on

How to install latest PHP on Windows 11

Setting up PHP on Windows manually has always been pain in the ass. So this tutorial is the most simple and basic PHP setup on Windows! Follow along

First you need is PHP binary which can be downloaded here . The link that I gave you is latest version of PHP which is 8.2 . It doesn't matter you can download whichever version you want.

Download the highlighted one

Once it has finished download you can extract it.

Extract

This part is important because beginners would usually think that is it a MUST to extract the PHP binary into C drive or default drive. Actually, this is not correct you can extract it anywhere you like. For my case I have special drive for development so I put it there.

Drive

For this part, you need to create your own empty folder and name it php:

Loading

The only thing necessary that you need to setup and make your PHP works on terminal is setting up the path. For this you need to go to Windows search and search for Environment

Environment

Click on the Environment Variables... button:

Click on the Environment Variables

Double click on path:

click on path

Click on browse:

Click on browse

Browse for the folder that you have extracted PHP in the before steps, note this is important just click on the folder and make sure it is highlighted and then click Ok:

Image description

If you have your terminal open, close it and open it back to ensure that the changes take effect. Now type on php -v VOiLLAA! php has been installed in your machine.

terminal

Guys, you might be thinking why don't just install XAMPP, Laragon or WAMPP? I've tried all of these tools before, personally I think knowing how things work in the background is very important.

And knowing your tools in any environment is crucial, it doesn't matter if you are on Windows, Linux or MAC try your best to setup anything yourself and not rely on 3rd party services.

And also those tools are very bloated and they also install unnecessary things on your machine.

Top comments (7)

Collapse
 
cavo789 profile image
Christophe Avonture

Forget this for always. Use Docker and you'll be able to play with all PHP versions, Postgresql, Mysql, ... just by editing a text file and changing f.i. php8.2 to php8.3 i.e. just replace 2 by 3 and it's done. Just one character and you're ok. Easier than this is difficult no ?
docker.com/products/docker-desktop/ and hub.docker.com/_/php.

Collapse
 
farhanhelmy profile image
Farhan Helmy

I agree with you, but some people don't have the docker knowledge. Also to create link between local file and inside docker is kinda complicated in my opinion

Collapse
 
cavo789 profile image
Christophe Avonture

I agree that Docker is a knowledge to acquire and, if you're not familiar with it, it can be difficult.

If you are talking about sharing files between the host and the container, it's the notion of volume. See -v CLI flag or the volume entry in composer.yaml file.

Collapse
 
nasrulhazim profile image
Nasrul Hazim Bin Mohamad

Laragon please. haha

Collapse
 
farhanhelmy profile image
Farhan Helmy

hshshshsh

Collapse
 
milanobrtlik profile image
Milan Obrtlik

Nice detailed tutorial. And if you're serious with it, next step is install & learn Docker.

Collapse
 
dhahri100 profile image
Ahmed Dhahri

thank u bro