🚀 Docker is the Standard
Gone are the days of XAMPP/WAMP. Modern Laravel development uses Laravel Sail, a light-weight command-line interface for interacting with Laravel's default Docker development environment.
1. Prerequisites
macOS:
- Install OrbStack (Recommended) or Docker Desktop.
Windows:
- Install WSL2 (Windows Subsystem for Linux).
- Install Docker Desktop and enable WSL2 integration.
- Important: All terminal commands must be run inside your WSL2 terminal (Ubuntu), not PowerShell.
2. Create a New Project
This command downloads a small Docker container to build your app without needing PHP installed on your local machine initially.
curl -s "https://laravel.build/my-app" | bash
You can customize the services (e.g., add Redis, MySQL):
curl -s "https://laravel.build/my-app?with=mysql,redis" | bash
3. Start the Environment
cd my-app
./vendor/bin/sail up -d
The first time you run this, it will take a few minutes to build the containers.
4. Configure Shell Alias
Typing ./vendor/bin/sail is tedious. Add an alias to your shell configuration (.zshrc or .bashrc):
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
Reload your shell, and now you can just type sail up, sail artisan, etc.
5. VS Code Setup
Install these extensions:
- PHP Intelephense (Ben Mewburn)
- Laravel Blade Snippets (Winnie Lin)
- Laravel Extra Intellisense
- Docker