码迷,mamicode.com
首页 > Web开发 > 详细

【记录】vscode 使用 WSL PHP

时间:2019-04-18 09:36:05      阅读:456      评论:0      收藏:0      [点我收藏+]

标签:ssi   com   tool   github   添加   exec   nal   mnt   sof   

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

Windows Host

d:\wsl-tools\php.bat

@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"

【记录】vscode 使用 WSL PHP

标签:ssi   com   tool   github   添加   exec   nal   mnt   sof   

原文地址:https://www.cnblogs.com/alanabc/p/10727285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!