Unless you install a third-party extension that provides its own custom PHP parser, Visual Studio Code just relies in the PHP interpreter you install in order to lint files. That's provided by the PHP Language Features builtin extension.
I will pick your PHP interpreter from your PATH
variable. A simple way to figure it out is to type php -v
in a CMD or PowerShell window:
C:\>php -v
PHP 8.1.15 (cli) (built: Jan 31 2023 23:50:48) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.15, Copyright (c) Zend Technologies
with Zend OPcache v8.1.15, Copyright (c), by Zend Technologies
If you didn't add it, or you want to use a different interpreter, you can set a custom path in the php.validate.executablePath
directive.
At the time of writing there isn't a visual editor for this setting so you'll need to edit it as JSON. Windows directory separator (\
) is a special character in JSON, so you need to either escape it or use Unix separator (/
)
"php.validate.executablePath": "C:\\PHP\\php.exe"
"php.validate.executablePath": "C:/PHP/php.exe"