12

When opening any PHP file in the Windows version of Visual Studio Code (version 0.10.1), I get the message:

Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'

I don't have PHP installed locally -- is there some way to turn off the automatic validation for PHP, either for the project or globally?

Ken
  • 1,691
  • 5
  • 22
  • 38

5 Answers5

16

Starting with version 0.10.5, there is a setting under the PHP Configuration Options section in settings.json to control validation. You can modify either the workspace settings or the global settings depending on what you want to accomplish.

// Whether php validation is enabled or not.
    "php.validate.enable": true,
Ashhar Hasan
  • 803
  • 14
  • 34
3

For Windows it doesn't seem to work since it starts as a null pointer.

"php.validate.executablePath": null

If you change it into something like:

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

and put an empty file (could be a text file) named as "php.exe" it stops showing the warning, although I do not know if there could be any side effects when VS Code actually tries to use it.

But I would like to add that installing php may be a better option. It just executes when called upon, so the only extra resource that you may end up using would be some hard drive space.

iaef
  • 55
  • 6
1

Not sure how to accomplish this in the Windows version. But for the Linux version (and Mac?):

Adding a path of /dev/null seems to suppress the message.

File -> Preferences -> User Settings (or Workspace Settings).

"php.validate.executablePath": "/dev/null"
Gordon Glas
  • 1,659
  • 2
  • 15
  • 23
  • Unfortunately, this technique doesn't seem to work with the **Windows** version. – Ken Nov 21 '15 at 22:25
  • Oops. I missed that. Sorry. Updated my answer in case anyone wanting to accomplish it under the Linux (and probably Mac) version. – Gordon Glas Nov 22 '15 at 14:35
0

Setting PHP validation to false in Preferences/User settings.json and/or Preferences/Workspace settings.json does currently work in Windows (year 2016, VSC Version 1.4.0) to end the validation messages. User preference settings are applied globally, while Workspace settings are applied to specific folders or projects.

Just to clarify what may not be obvious to newbies, custom settings in User 'settings.json' and Workspace 'settings.json' pages must be bracketed, otherwise the defaults will not be overwritten.

After the settings have been entered, the page must be saved (File/Save). A backup of 'settings.json' may be exported via Save As by changing the file name and/or choosing another folder. For example, 'myfolder\2017-01-01_vsc_user_settings.json'. To use the backup file, open it in VSC and copy/paste the code back into Preferences/User or Preferences/Workplace 'settings.json'.

https://code.visualstudio.com/docs/customization/userandworkspace

Turn off PHP validation: settings.json

// Place your settings in this file to overwrite default and user settings.
{
"php.validate.enable": false
}

Use comma separators to overwrite multiple default settings: settings.json.

// Place your settings in this file to overwrite default and user settings.
{
"php.validate.enable": false,
"files.trimTrailingWhitespace": true,
"editor.autoClosingBrackets": false,
"editor.wordWrap": true
}
1keown
  • 73
  • 1
  • 7
-1

If you are opening a php file in visual studio code, then I assume you would like to use intellisense. Just install the extension PHP Debug in Visual Studio Code, and follow all the instructions till you create and save the JSON file in Visual Studio Code.