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.
This question is related to
visual-studio-code
php-7
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.
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"
}
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 :
64-bit or 32-bit version of php (x64 or x86), depending on your OS;
some librairies like Visual C++ Redistributable for Visual Studio 2015 : http://www.microsoft.com/en-us/download/details.aspx?id=48145;
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"
Source: Stackoverflow.com