Table of Contents
If you want to create a PHP project on Windows 11, this guide gives you everything you need to get started. You already have PHP installed — now it is time to write real code, structure your project properly, and run it in a browser.
By the end of this post, you will have a working project folder, a proper file structure, and a page running live on your local machine. Let us get into it.

Before You Start
You need two things before you write a single line of code:
- PHP installed on Windows 11 — if you have not done this yet, go through our PHP installation guide first and come back here.
- A code editor — download Visual Studio Code if you do not have one. It is free, lightweight, and has brilliant PHP support.
That is honestly all you need. No XAMPP, no Apache, nothing extra.
Step 1: Set Up the Folder for Your PHP Project on Windows 11
Start by giving your project a home. Open File Explorer and create a new folder somewhere clean — the root of your C drive works well:
C:\projects\my-first-php-app
Why C:\projects? Because short paths without spaces save you a lot of headaches later, especially when you start working with command-line tools. Trust me on this one.
Step 2: Open the Project in VS Code
Open VS Code, go to File → Open Folder, and select your new project folder. You now have a clean workspace staring back at you.
One Extension Worth Installing
Before you write any code, grab the PHP Intelephense extension. Hit Ctrl + Shift + X, search for it, and install it. It adds autocomplete, real-time error checking, and function hints — things that make PHP development feel much smoother, especially when you are just starting out.
Step 3: Write Your First PHP File
Create a new file inside your project folder and name it index.php. This is your entry point — the first file your browser will load. Add this to it:
" . $message . "";
echo "Built by: " . $name . "";
?>
Save the file with Ctrl + S. That is it — you just wrote your first PHP file.
What Does This Code Actually Do?
Here is a quick breakdown so you are not just copying and pasting blindly:
tells the server — "everything inside here is PHP, run it."$nameand$messageare variables. All PHP variables start with$.echosends the output to the browser. Think of it as PHP’s way of printing text.- The
.joins two strings together — that is called concatenation.
Step 4: Run Your Project in the Browser
Here is something most beginners do not know — PHP ships with its own built-in web server. You do not need to install Apache or XAMPP just to see your project in a browser.
Open Command Prompt, navigate to your project folder, and fire up the server:
cd C:\projects\my-first-php-app
php -S localhost:8000
Now open your browser and visit http://localhost:8000. Your page should load instantly with the welcome message you just wrote.
When you are done, press Ctrl + C in Command Prompt to stop the server.
Step 5: Organise Your Project Before It Gets Messy
Right now you have one file and that is fine. But good habits start early. Here is a simple folder structure that scales well as your project grows:
my-first-php-app/
├── index.php
├── config.php
├── /includes
│ ├── header.php
│ └── footer.php
└── /assets
└── style.css
How to Include One File Inside Another
Once you create includes/header.php, you can pull it into any page with one line:
This keeps your code clean and avoids copy-pasting the same HTML on every page. It is one of the most useful PHP habits you can pick up early.
You Are All Set
You now know exactly how to create a PHP project on Windows 11 — from an empty folder to a running page in your browser. This foundation applies to every PHP project you build going forward, whether it is a simple script or a full web application.
The next logical step is connecting your project to a database. When you are ready, jump into our next guide: How to Connect PHP to MySQL on Windows 11 →
Frequently Asked Questions
Do you need XAMPP to create a PHP project on Windows 11?
No, you do not. PHP has a built-in development server that you start with php -S localhost:8000. XAMPP is useful if you also need Apache and MySQL set up together, but for a basic PHP project it is completely unnecessary.
What is the best code editor for writing PHP on Windows?
Visual Studio Code with the PHP Intelephense extension is hard to beat — it is free, fast, and gives you smart autocomplete and error detection right inside the editor. A lot of professional PHP developers use it daily.
Why should you name your main file index.php?
Web servers automatically look for index.php when someone visits your site without specifying a filename. If you name it something else, visitors get a 404 error unless you configure your server to look for a different default file.
What is the difference between include and require in PHP?
Both pull in another PHP file, but they behave differently when the file is missing. include throws a warning and keeps running. require throws a fatal error and stops everything. Use require for files your project cannot function without, like a config or database connection file.
Can you connect this PHP project to a MySQL database?
Absolutely. Once you enable pdo_mysql in your php.ini file, you can connect to any MySQL or MariaDB database using PDO. It is the cleanest and most secure way to handle database connections in PHP.
