来自GitHub上的一个issue:Is it possible to use wsl bash php for php.validate.executablePath

Windows Host

d:\wsl-tools\php.bat

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
@echo OFF
setlocal ENABLEDELAYEDEXPANSION

rem Collect the arguments and replace:
rem  '\' with '/'
rem  'd:' with 'mnt/d'
rem  '"' with '\"'
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:D:=/mnt/d%
set v_params=%v_params%
set v_params=%v_params:"=\"%

rem Call the windows-php inside WSL.
rem windows-php is just a script which passes the arguments onto
rem the original php executable and converts its output from UNIX
rem syntax to Windows syntax.
C:\Windows\system32\bash.exe -l -c "windows-php %v_params%"

WSL

/usr/local/bin/windows-php

#!/bin/bash
# Pass all the arguments to PHP.
output=$(php "$@")
# Perform UNIX->WINDOWS syntax replacements.
output="${output//$'\n'/$'\r'$'\n'}"
output="${output//\/mnt\/d/D:}"
output="${output//\//\\}"
# Echo corrected output.
echo $output

tips:记得添加执行权限

VSCode in Windows Host

setting:

"php.validate.executablePath": "d:\\wsl-tools\\php.bat"
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄