PHP
PHP development environment with Laravel Herd, Docker (WSL 2) and takeout.
Prerequisites
Install the following:
PHP
Install and launch Laravel Herd.
- Skip Herd Pro
- Enable "Automatically launch Herd on system startup"
Ubuntu
Setup Ubuntu 24:
ubuntu2404exitwsl --setdefault Ubuntu-24.04wsl -t Ubuntu-24.04ubuntu2404Add user to Docker group:
sudo usermod -aG docker ${USER}TIP
Make sure Docker is running if you get an error like usermod: group 'docker' does not exist.
Takeout
Takeout is a CLI tool for spinning up docker containers for services like MySQL or Redis.
Add an alias to access takeout via Docker:
Add-Content -Path $PROFILE.CurrentUserAllHosts -Value 'function takeout { docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest $args }'Restart PowerShell.
takeoutTIP
Make sure Docker is running if you get an error like docker: error during connect.
VS Code
To access the Herd binaries in the integrated terminal of VS Code, add the following config:
"terminal.integrated.env.windows": {
"PATH": "${env:PATH};${env:USERPROFILE}\\.config\\herd\\bin"
},PhpManager
Install PhpManager to install additional extensions:
Install-Module -Name PhpManagerExample usage with imagick and PHP 8.3:
Install-PhpExtension imagick -Path $env:USERPROFILE\.config\herd\bin\php83Enable-PhpExtension imagick -Path $env:USERPROFILE\.config\herd\bin\php83Enable-PhpExtension can also be used to enable default extensions such as xsl which are disabled by default:
Enable-PhpExtension xsl -Path $env:USERPROFILE\.config\herd\bin\php83Valet alias
Add a valet alias for herd in case muscle memory kicks in:
Add-Content -Path $PROFILE.CurrentUserAllHosts -Value 'function valet { herd @Args }'Restart PowerShell.
Platform requirements
Ignore incompatible platform requirements such as ext-pcntl, for example when installing Laravel Horizon in a cross-platform project:
Add-Content -Path $PROFILE.CurrentUserAllHosts -Value '$env:COMPOSER_IGNORE_PLATFORM_REQ = "ext-pcntl,ext-posix"'Restart PowerShell.