php 在docker容器内设置php时,如何在vscode中设置php可执行路径php.validate.executablePath?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43768614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set php executable path php.validate.executablePath in vscode when php is set inside docker container?
提问by Nicolas Takashi
I have a development environment based in docker.
我有一个基于 docker 的开发环境。
Everytime that I open VSCode I get this message:
每次打开 VSCode 时,都会收到以下消息:
Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.
由于未设置 PHP 可执行文件,因此无法验证。使用设置 'php.validate.executablePath' 来配置 PHP 可执行文件。
Somebody know how to set php.validate.executablePath in this case?
有人知道在这种情况下如何设置 php.validate.executablePath 吗?
I have no idea how to do it.
我不知道该怎么做。
回答by Mohamed Elrashid
回答by Yugandhar
For linux users:
if you don't have PHP installed then first download,
then in terminal type
对于 linux 用户:如果您没有安装 PHP,请先下载,
然后在终端输入
$ whereis php
$ whereis php
and it will show path for php executable (It will be either in /usr/bin/php
or usr/local/bin/php
) which you can copy from terminal.
它将显示 php 可执行文件的路径(它将在/usr/bin/php
或 中usr/local/bin/php
),您可以从终端复制该路径。
In VScode goto settings.json
file and paste
在 VScode 中转到settings.json
文件并粘贴
php.validate.executablePath: /usr/bin/php
php.validate.executablePath: /usr/bin/php
回答by Julian
Sure, easy. Just follow what it's says.
当然,容易。只要按照它说的去做。
Go to File> Preferences > Settings ... it will open the settings.json file.
转到文件>首选项>设置...它将打开settings.json文件。
add the following code:
添加以下代码:
{"php.validate.executablePath": "Here you put your PHP.exe path"}
{"php.validate.executablePath": "这里是你的 PHP.exe 路径"}
You have to know where te PHP.exe file is in your computer, search in the php>bin folder.
您必须知道 te PHP.exe 文件在您的计算机中的位置,在 php>bin 文件夹中搜索。
Hope it works for you
希望这对你有用
回答by ray
回答by Caique Andrade
My case, I'm using Laragon, so you should search where is your php.exe.
我的情况,我使用的是 Laragon,所以你应该搜索你的php.exe在哪里。
By VSCodejust add.
通过VSCode只需添加。
"php.executablePath": "C:\laragon\bin\php\php-7.2.19-Win32-VC15-x64\php.exe"
on settings.json.
在settings.json 上。
回答by Ralph Anthony
I simply used double forward slashes and it worked, like so: "php.validate.executablePath": "C:\xampp\php\php.exe",
我只是使用了双正斜杠,它的工作原理如下: "php.validate.executablePath": "C:\xampp\php\php.exe",
回答by Ian Croasdell
"php.validate.executablePath": "C:/php/php.exe"
wont work due to incorect escaping
"php.validate.executablePath": "C:/php/php.exe"
由于不正确的转义而无法工作
try this;
尝试这个;
"php.validate.executablePath": "C:\php\php.exe"
回答by R Mac
If you get this on windows in VS code click on the blue 'open settings' button. Near the bottom of the screen this opens there's a link to enter the settings, click this to open the settings.json file. Edit the file to look like this:
如果您在 VS 代码中的 Windows 上获得此信息,请单击蓝色的“打开设置”按钮。在打开的屏幕底部附近有一个输入设置的链接,单击它打开 settings.json 文件。将文件编辑为如下所示:
{
"php.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe",
"php.validate.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe"
}
where C:/php-7.4.2-nts-Win32-vc15-x64 is the path to your PHP dir
其中 C:/php-7.4.2-nts-Win32-vc15-x64 是 PHP 目录的路径
回答by Nuuu
Download PHP, in my case, I downloaded from here: http://windows.php.net/download/
下载 PHP,就我而言,我是从这里下载的:http: //windows.php.net/download/
Copy and paste the files to a location on your computer, and set the path:
将文件复制并粘贴到计算机上的某个位置,并设置路径:
"php.validate.executablePath": "C:/php/php.exe"
"php.validate.executablePath": "C:/php/php.exe"
回答by Sebastian Mansfield-Barry
I also got this error message. The path to php.exe
was already set in my System Environment Variables.
我也收到了这个错误信息。路径php.exe
已经在我的系统环境变量中设置。
The error went away when I commented out "php.validate.executablePath": "c:/path/to/php7.2.10/php.exe"
, in the settings.json
file in VSCode.
当我在 VSCode"php.validate.executablePath": "c:/path/to/php7.2.10/php.exe"
的settings.json
文件中注释掉时,错误消失了。