2016-09-24 6 views

Antwort

1

Dies ist mit einer Old-School-Batch-Datei möglich. weder

php.bat

@echo off 
c:\windows\sysnative\bash.exe -c "php %*"` 

setting.json

"php.validate.executablePath": "c:\\PATH_TO\\php.bat" 
+0

Nun, ich habe es getestet, aber ich konnte es nicht funktionieren. – palci12

+0

Ersetzen Sie für php.bat "sysnative" durch "system32" und entfernen Sie das 'vom Ende der Zeichenfolge. –

1

Die andere Antwort ist nicht für mich arbeiten: nach einiger Arbeit kam ich mit diesen beiden Skripte auf:

Diese Einer heißt php.bat und ich platzierte ihn in C:\wsl-tools\:

@echo OFF 
setlocal ENABLEDELAYEDEXPANSION 
rem Collect the arguments and replace: 
rem '\' with '/' 
rem 'c:' with 'mnt/c' 
rem '"' with '\"' 
set v_params=%* 
set v_params=%v_params:\=/% 
set v_params=%v_params:C:=/mnt/c% 
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\sysnative\bash.exe -l -c "windows-php %v_params%" 

Dieser heißt windows-php und befindet sich irgendwo im WSL-Pfad (ich habe /usr/local/bin gewählt).

# Pass all the arguments to PHP. 
output=$(php "[email protected]") 
# Perform UNIX->WINDOWS syntax replacements. 
output="${output//$'\n'/$'\r'$'\n'}" 
output="${output//\/mnt\/c/C:}" 
output="${output//\//\\}" 
# Echo corrected output. 
echo $output 

Einstellung "php.validate.executablePath": "c:\\wsl-tools\\php.bat" funktioniert für mich.

Hinweis:

Vielleicht möchten this issue und this pull request folgen, wie es aussieht, dieses Problem offiziell in einer der nächsten Versionen behoben werden soll.

+0

Für die x64-Version von Visual Studio Code müssen Sie die letzte Zeile des ersten Skripts ändern in: C: \ Windows \ system32 \ bash.exe -l -c "Windows-PHP% v_params%" – hdomos

Verwandte Themen