[visual-studio-code] PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting

I'm running windows 10 fresh copy and I just installed visual studio code. I was trying to develop a PHP project using VS Code. But I'm having trouble in setting up the environment.

I saw a blog post and I downloaded the binary file of PHP 7 and place it in the "C" drive. Then I set path variable too.

But still, I'm getting this issue.

enter image description here

This question is related to visual-studio-code php-7

The answer is


Try this !!!. This will solve your problem for sure!

Method 1 -

Step 1 - Go to 'Environmental Variables'.

Step 2 - Find PATH variable and add the path to your PHP folder.

Step 3 - For 'XAMPP' users put 'C:\xampp\php' and 'WAMP' users put 'C:\wamp64\bin\php\php7.1.9' ) and save.

Method 2-

In VS Code

File -> Preferences -> Settings.

enter image description here

Open 'settings.json' file and put the below codes.

If you are using WAMP put this code and Save.

  "php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.1.9\\php.exe",
  "php.executablePath": "C:\\wamp64\\bin\\php\\php7.1.9\\php.exe"

If you are using XAMPP put this code and Save.

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

Note - Replace php7.1.9 with your PHP version.


For me it was important to delete the "php.executablePath" path from the VS code settings and leave only the path to PHP in the Path variable.

When I had the Path variable together with php.executablePath, an irritating error still occurred (despite the fact that the path to php was correct).


For me this setting was working.
In my windows 8.1 the path for php7 is

C:\user\test\tools\php7\php.exe

settings.json

 {  
 "php.executablePath":"/user/test/tools/php7/php.exe",
 "php.validate.executablePath": "/user/test/tools/php7/php.exe"
 }

see also https://github.com/microsoft/vscode/issues/533


This one also works

  1. Remove the "php.executablePath" line from the VS code settings.

  2. Then add the xampp php path to the System variables

enter image description here

enter image description here

After that restart the Visual Studio Code


After adding php directory in User Settings,

{
    "php.validate.executablePath": "C:/phpdirectory/php7.1.8/php.exe",
    "php.executablePath": "C:/phpdirectory/php7.1.8/php.exe"
}

If you still have this error, please verify you have installed :

To test if you PHP exe is ok, open cmd.exe :

c:/prog/php-7.1.8-Win32-VC14-x64/php.exe --version

If PHP fails, a message will be prompted with the error (missing dll for example).


For those who are using xampp:

File -> Preferences -> Settings

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