How to set php executable path php.validate.execut

2020-02-17 07:15发布

问题:

I have a development environment based in docker.

Everytime that I open VSCode I get this message:

Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.

Somebody know how to set php.validate.executablePath in this case?

I have no idea how to do it.

回答1:

Here is a screenshot.

  • Don't forget to escape \
  • You don't have to add it to the Path



回答2:

Sure, easy. Just follow what it's says.

Go to File> Preferences > Settings ... it will open the settings.json file.

add the following code:

{"php.validate.executablePath": "Here you put your PHP.exe path"}

You have to know where te PHP.exe file is in your computer, search in the php>bin folder.

Hope it works for you



回答3:

I had the same problem but found the fix here.

In Windows:

  1. Go To System Properties
  2. Go To Advanced Tab
  3. Click "Environment Variables"
  4. Select Path
  5. Add a new path that points to your php 7 executable:



回答4:

For linux users: if you don't have PHP installed then first download,
then in terminal type

$ 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.

In VScode goto settings.json file and paste

php.validate.executablePath: /usr/bin/php



回答5:

"php.validate.executablePath": "C:/php/php.exe" wont work due to incorect escaping

try this;

"php.validate.executablePath": "C:\\php\\php.exe"


回答6:

Download PHP, in my case, I downloaded from here: 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"



回答7:

I also got this error message. The path to php.exe was already set in my System Environment Variables.

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.