This is a fix for the following error when opening PHP files in VSCode or VSCodium:
Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.
This error means that VSCode does not know how to validate the contents of a PHP file and can’t show errors in the file if any.
To fix this, open the settings.json file in VSCode, either by clicking on the error message or using Ctrl+Shift+P > Open settings.json. In this file, you need to add the following lines and replace
[pathToPHP] with the path in your system:
To find php’s path, in your Linux Terminal run
Copy the path and paste it into
settings.json i.e., replace
[pathToPHP] in the above example with the output of the above command.
Restart VSCode and the error should be fixed.