Fix PHP executable not set in VSCode when running XAMPP on Linux

Add RSS feed to Reader and sync to Readwise.

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:

"php.executablePath": [pathToPHP]
Code language: JSON / JSON with Comments (json)

To find php’s path, in your Linux Terminal run

whereis php

Copy the path and paste it into settings.json i.e., replace [pathToPHP] in the above lines with the output of the whereis command. There may be multiple results for the command. To pick the correct one:

  • If you’ve installed PHP as part of XAMPP, the location of PHP will be in a subfolder of /opt/lampp/
  • Otherwise PHP will be under the /usr/bin folder, for example, /usr/bin/php7.4 or /usr/bin/php

Restart VSCode and the error should be fixed.


Leave a Reply

Your email address will not be published. Required fields are marked *