With Ubuntu 20.04 LTS as distro.
The goal is to use PHP from windows under WSL, without installing PHP on the linux distro.
Editing ~/.bash_profile
, add this lines.
alias php='php.exe'
alias phpdbg='phpdbg.exe'
alias composer='cmd.exe /c composer'
Using directory C:\phpini
for additionnal ini files, with a php module (PHP ts).
SetEnv PHP_INI_SCAN_DIR "C:/phpini"
LoadModule php7_module <the_module>
With PHP nts, environment variables is required.
- In Advanced System Setting (fr-FR Paramètres système avancés), click Environment Variables... (fr-FR Variables d'environnement...).
- In System Variables, add
PHP_INI_SCAN_DIR
In Advanced System Setting, add or extend WSLENV
with value PHP_INI_SCAN_DIR/p
More infirmations here : share environment vars between wsl and windows