This Gist provides a small wrapper script to run PHP inside Docker from WSL, without installing PHP locally.
- WSL installed
- Docker Desktop installed and enabled for your WSL distro
- Bash
Save the script as php:
chmod +x phpOptional: move it somewhere in your PATH:
mkdir -p ~/.local/bin
mv php ~/.local/bin/phpMake sure ~/.local/bin is in your PATH.
Run PHP files from any directory:
php script.phpRun inline PHP:
php -r 'echo PHP_VERSION . PHP_EOL;'The script uses the official php:8.5-cli Docker image and mounts your current working directory, so files are available inside the container.