If you are a PHP developer on Windows, you generally fall into one of two camps: the XAMPP veterans or the Laragon fans.
Laragon users always brag about one specific feature: “Quick App.” They click one button, and Laragon downloads WordPress, extracts it, creates a database, and sets up the URL. Meanwhile, XAMPP users are stuck doing the “manual dance”:
- Go to WordPress.org and download the zip.
- Extract the zip (wait for Windows to process 3,000 files…).
- Rename the folder so it isn’t just called
wordpress. - Open
localhost/phpmyadmin. - Manually create a database.
- Finally run the installer.
I love the stability of XAMPP, but I hated that workflow. So, I wrote a script to fix it.
Here is how to use a simple PowerShell script to automate the entire process, making XAMPP just as fast as Laragon.
The Solution: One Script to Rule Them All
We can use Windows PowerShell to mimic Laragon’s automation. This script will:
- Ask you for a project name.
- Download the latest WordPress zip.
- Extract it directly to your
C:\xampp\htdocsfolder. - Auto-create the database (using the XAMPP default
rootuser). - Open your browser to the setup page.
The Code
Save the following code as install-wp.ps1 somewhere on your computer (I keep mine right inside the C:\xampp folder).
<#
.SYNOPSIS
Automated WordPress Installer for XAMPP
.DESCRIPTION
Downloads latest WP, extracts to htdocs, creates DB, and launches browser.
#>
# --- CONFIGURATION ---
$xamppPath = "C:\xampp"
$htdocsPath = "$xamppPath\htdocs"
$mysqlPath = "$xamppPath\mysql\bin\mysql.exe"
$wpUrl = "https://wordpress.org/latest.zip"
# ---------------------
Clear-Host
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " XAMPP FAST WORDPRESS INSTALLER" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
# 1. Get Project Name
$projectName = Read-Host -Prompt "Enter your project name (e.g. mysite)"
if ([string]::IsNullOrWhiteSpace($projectName)) {
Write-Error "Project name cannot be empty."
exit
}
$targetDir = "$htdocsPath\$projectName"
# Check if folder exists
if (Test-Path $targetDir) {
Write-Warning "Folder '$projectName' already exists in htdocs. Please choose a different name."
exit
}
# 2. Download WordPress
Write-Host "`n[1/5] Downloading latest WordPress..." -ForegroundColor Yellow
$tempZip = "$env:TEMP\wordpress_latest.zip"
try {
Invoke-WebRequest -Uri $wpUrl -OutFile $tempZip
}
catch {
Write-Error "Failed to download WordPress. Check your internet connection."
exit
}
# 3. Extract Files
Write-Host "[2/5] Extracting files..." -ForegroundColor Yellow
# Extract to a temp location first to handle the 'wordpress' subfolder issue
$tempExtractDir = "$env:TEMP\wp_temp_$projectName"
Expand-Archive -Path $tempZip -DestinationPath $tempExtractDir -Force
# Move the actual files to the final htdocs destination
Write-Host "[3/5] Setting up folder structure..." -ForegroundColor Yellow
Move-Item -Path "$tempExtractDir\wordpress" -Destination $targetDir
# Cleanup Temp Files
Remove-Item $tempZip -Force
Remove-Item $tempExtractDir -Recurse -Force
# 4. Create Database
Write-Host "[4/5] Creating Database '$projectName'..." -ForegroundColor Yellow
if (Test-Path $mysqlPath) {
$createDbQuery = "CREATE DATABASE $projectName;"
# Run MySQL command. Standard XAMPP root has no password.
& $mysqlPath -u root -e $createDbQuery
Write-Host "Database created successfully." -ForegroundColor Green
}
else {
Write-Error "MySQL executable not found at $mysqlPath. Is XAMPP installed in C:\xampp?"
}
# 5. Launch Browser
Write-Host "[5/5] Launching Installer..." -ForegroundColor Green
Start-Process "http://localhost/$projectName"
Write-Host "`n------------------------------------------"
Write-Host "Done! Setup is ready for '$projectName'." -ForegroundColor Cyan
Write-Host "Database Name: $projectName"
Write-Host "User: root"
Write-Host "Pass: (empty)"
Write-Host "------------------------------------------"
How to Use It
- Start XAMPP: Make sure Apache and MySQL are running (Green status).
- Run the Script: Right-click your
install-wp.ps1file and select “Run with PowerShell”. - Enter Name: Type your desired project name (e.g.,
client-site) and hit Enter.
That’s it.
The script will handle the downloading and extracting. It connects to MySQL via the command line to create the database for you. In about 30 seconds, your default browser will pop open with the WordPress installation screen.
When WordPress asks for database details, simply use:
- Database Name: (The name you typed in the script)
- Username: root
- Password: (leave empty)
Troubleshooting
If the window closes immediately or you see red text about permissions, you likely need to allow script execution on your PC one time. Open PowerShell as Administrator and run:
Set-ExecutionPolicy RemoteSigned
Summary
You don’t need to switch tools to get a modern workflow. With a little bit of scripting, XAMPP is still a powerhouse for local development.

Leave a Reply
You must be logged in to post a comment.