How to Set Up a Simple PHP Dev Environment on Windows (Beginner Guide)
If you’re learning PHP, the first thing you need is a way to run it on your own computer. That’s called a local development environment. It lets you write PHP files and see them run in your browser without uploading anything to the internet.
In this guide, I’ll show you two easy ways to do it on Windows:
- Option 1: A barebones PHP setup (manual, lightweight, great for learning how things work)
- Option 2: Laragon (by far the easiest and fastest way to get started)
By the end, you’ll have PHP running locally and a test page working in your browser.
What You Need
- A Windows PC
- Internet connection
- A text editor (VS Code, Notepad++, or similar)
- About 10–15 minutes
No paid software needed.
Option 1: Barebones PHP Setup (Manual but Lightweight)
This method uses PHP’s built-in web server. It’s simple, fast, and helps you understand what’s actually going on under the hood.
What baffles some people when starting out is that PHP doesn’t need to be ‘installed’ in the traditional sense – you instead can just download and run.
Step 1: Download PHP
Go to php.net and click the big ‘Download’ button on the home page – this will take you to a page with lots of options! But don’t worry – it is relatively straightforward!
For most people starting out on a windows computer, the package you want to download will be the VS17 x64 Thread Safe version – click the link to the Zip file to start the download.
Once downloaded you need to extract the ZIP file to a folder, and then move all the files to a location to run PHP from – I would recommend just putting this in the root of your hard drive – for example:C:\php
That’s it – PHP installed!
Step 2: (Optional) Add PHP to Your PATH
If you want to run PHP in your command prompt (you probably do!) – This step just makes it easier.
- Open Environment Variables in Windows. You can do this by hitting Win + R on your keyboard and typing: sysdm.cpl
- When the system properties box appears – click the ‘Advanced’ tab, and then the ‘Environment Variables’ button at the bottom
- Under the ‘System variables’ list, there should be a variable called ‘Path’ – select that and click ‘Edit’
- Now click the ‘New’ button followed by ‘browse’ and select the path to the folder you have just put PHP – for example
C:\php - Once clicked ok out of those dialogs, Open Command Prompt and run:
php -v
If you see a PHP version number, it’s working.
If you skip this step, you can still run PHP by navigating to the PHP folder first.
Step 3: Create a Simple Project Folder
Create a folder somewhere, for example:
C:\projects\hello-php
Inside that folder, create a file called:
index.php
Step 4: Your First PHP File
Open index.php and add:
<?php
echo "Hello, PHP is working!";
Save the file.
Step 5: Run PHP’s Built-in Server
Open Command Prompt and navigate to your project folder:
cd C:\projects\hello-php
Then run:
php -S localhost:8000
Now open your browser and go to:
http://localhost:8000
You should see:
Hello, PHP is working!
Step 6: Test with phpinfo()
Change your index.php to this:
<?php
phpinfo();
Refresh the page. You should see a big info page showing your PHP version and settings. This confirms PHP is running correctly.
Pros and Cons of the Barebones Setup
Pros:
- Very lightweight
- No extra software
- You learn how PHP actually runs
Cons:
- No database included
- No automatic project URLs
- More manual setup as projects get bigger
This is great for learning, but it can get annoying once you start building real projects.
Option 2: Using Laragon (The Easiest Way)
If you just want to get coding quickly, Laragon is the simplest option.
What Is Laragon?
Laragon is an all-in-one local development environment for Windows. It includes:
- PHP
- A web server (Apache or Nginx)
- MySQL / MariaDB
- Handy tools for PHP, Laravel, WordPress, and more
It’s fast, lightweight, and almost zero setup.
Download and Install Laragon
- Go to laragon.org and download Laragon.
- Install it using the default options.
That’s it.
You can then use the laragon menu’s to create new projects and automatically set up a database and host file entry for convenient testing
Why Laragon Is So Convenient
- Automatically sets up:
- Web server
- PHP
- Database
- Project URLs
- Easy to switch PHP versions
- Great for:
- PHP projects
- Laravel
- WordPress
- General web development
Barebones PHP vs Laragon
Here’s the simple comparison:
- Setup time:
- Barebones: A few manual steps
- Laragon: About 2 minutes
- Beginner friendly:
- Barebones: OK
- Laragon: Very good
- Includes database:
- Barebones: No
- Laragon: Yes
- Best for:
- Barebones: Learning how PHP works
- Laragon: Building projects quickly
Which One Should You Choose?
- If you want to understand the basics of how PHP runs, try the barebones setup.
- If you want to actually build things with less hassle, use Laragon.
Honestly, I’d recommend starting with Laragon and coming back to the barebones approach later when you’re curious about what’s happening behind the scenes.
Common Problems and Fixes
phpis not recognized as a command
→ PHP is not in your PATH. Either add it or run PHP from its folder.- Port already in use
→ Try another port, for example:php -S localhost:8080 - White page in browser
→ Turn on error reporting or check for syntax errors in your PHP file.
What’s Next?
Now that you’ve got PHP running locally, you can:
- Build a simple PHP project
- Connect to a database
- Try a framework like Laravel
Why not try our tutorial on creating a simple contact form, where I’ll walk through creating your first small PHP project step by step.
