This guide will help you set up a local Symfony development environment on Windows using WSL2 (Windows Subsystem for Linux).
Note: Symfony applications work best with UNIX-based systems. This guide uses WSL2 to provide a native Linux environment on Windows, ensuring optimal performance and compatibility.
Open Command Prompt or PowerShell as Administrator and run:
wsl --versionEnsure your WSL version is 0.67.6 or higher. If WSL is not installed or needs updating, follow the official Microsoft guide.
wsl --install UbuntuThis will install Ubuntu as a virtual machine within WSL.
After Ubuntu is installed, enter WSL and configure systemd:
sudo nano /etc/wsl.confAdd the following content:
[boot]
systemd=trueSave and exit (Ctrl + X, then Y, then Enter).
Restart the Ubuntu VM from Command Prompt:
wsl --terminate UbuntuThen start Ubuntu again from the Start menu.
Inside the Ubuntu terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Add Homebrew to your PATH:
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> ~/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew --versionThe Symfony CLI and some packages require build tools:
sudo apt-get update
sudo apt-get install -y gcc make
gcc --versionInstall Docker Engine directly inside WSL:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
sudo gpasswd -a $USER docker
rm get-docker.sh
sudo systemctl enable docker.service
sudo systemctl enable containerd.serviceLog out and back in, or run newgrp docker for the group changes to take effect.
Note: The following alternatives may work but have not been tested with this guide. Instructions may be incomplete.
- Docker Desktop for Windows - GUI application with WSL2 backend integration (licensing may apply)
For optimal performance, always work within the Linux filesystem, not the mounted Windows drives.
# Good - Fast performance
cd ~/projects/my-symfony-app
# Bad - Slow performance
cd /mnt/c/Users/YourName/projects/my-symfony-appCreate a workspace directory:
mkdir -p ~/projects
cd ~/projectsgit clone <your-repository-url>
cd your-project-nameCopy the following templates to your Symfony project root:
- Brewfile - Homebrew dependencies
- Makefile - Automation commands
- docker-compose.yaml - Container services
Important: Review and customize the templates according to your project needs. The templates work well for typical Symfony applications, but you may need to:
- Adjust the PHP version in the Brewfile (e.g.,
php@8.4instead ofphp@8.5) - Enable/disable PHP extensions your project requires
- Remove services you don't need (e.g., RabbitMQ if not using async messaging)
- Add additional services (e.g., Redis, Elasticsearch)
For project-specific Symfony CLI configuration (e.g., .php-version, .symfony.local.yaml), see the Symfony CLI documentation.
Tip: You can access your WSL files from Windows Explorer at
\\wsl$\Ubuntu\home\<username>\.
make installThis command will:
- Execute
brew bundleto install all dependencies from the Brewfile - Install PHP with necessary extensions
- Install Composer
- Install the Symfony CLI
To access your local HTTPS server from Windows browsers, import the Symfony certificate:
- Open the certificate folder. Either run this from WSL:
Or navigate manually in Windows Explorer to
explorer.exe `wslpath -w $HOME/.symfony5/certs`\\wsl$\Ubuntu\home\<username>\.symfony5\certs\ - Double-click
default.p12 - Follow the Certificate Import Wizard
- Install to "Local Machine" > "Trusted Root Certification Authorities"
make runWhen complete, you should see:
[OK] Web server listening
The Web server is using PHP FPM 8.x
https://127.0.0.1:8000
Access your app in Windows at https://localhost:8000.
- Open Settings > Network & Internet > Proxy
- Enable Use setup script
- Set Script address to:
http://localhost:7080/proxy.pac - Click Save
For more details, see Windows proxy settings guide.
Inside WSL:
make proxy-attach DOMAIN=my-appYour app will now be available at https://my-app.wip.
Visual Studio Code is strongly recommended for WSL development. It has seamless WSL integration:
- Install VS Code on Windows
- Install the Remote - WSL extension
- Open your project:
code ~/projects/your-project-name
This provides a native development experience while running code in Linux.
If you encounter DNS resolution issues, add a public DNS server:
echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.confIf Homebrew seems stuck or unresponsive:
- Press
Ctrl + Cto cancel the current process - Run
brew doctorto diagnose issues - Follow any recommendations shown
- Try
make installagain
If you see Command 'brew' not found:
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
source ~/.bashrcsudo gpasswd -a $USER docker
newgrp docker # Or log out and back inIf your project is running slowly:
- Ensure your project is in the Linux filesystem (
~/), not/mnt/c/ - Avoid cross-filesystem operations
If WSL fails to start:
wsl --shutdown
wslsymfony server:stop --all # Stop all Symfony servers
# If the above doesn't work, find and kill the process manually
lsof -i :8000 # Find the process using the port
kill -9 <PID> # Kill the process (replace <PID> with actual ID)
make run # Try again