I want to config Visual Studio Code (VSC) to work with php on linux (Ubuntu).
I installed xammp for this purpose and I don't know where to point this parameter on VSC php.validate.executablePath
On windows the config path has to be like this: "php.validate.executablePath": "c:/php/php.exe"
Could you give me the full path to configure it properly ON LINUX?
Regards
This answer may change based on what flavor of Linux/Unix you are using, but if you are using Ubuntu like me, this is how I did it.
First and foremost, I know you're using XAMPP, but do exactly what the error message says and install PHP7. You can do so by running
sudo apt-get install php
.
I know that goes against intuition. At first I thought "I have XAMPP installed, which installed PHP. Why do I need to install PHP?" XAMPP only includes the PHP runtime executables. In order to do development with PHP, you need to install the full environment. XAMPP will continue to use its built-in version.
Once the install is completed, follow these steps:
Execute whereis php
. Example output below:
php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.0-json /usr/share/php7.0-opcache /usr/share/php /usr/share/php7.0-readline /usr/share/php7.0-common /opt/lampp/bin/php /usr/share/man/man1/php.1.gz
In Visual Studio Code, click the cog in the bottom left corner and select Settings. On the right-hand pane, insert the following code. The version-agnostic path is used here:
"php.validate.executablePath": "/usr/bin/php"
Press Control+S or click File -> Save
The final settings file should look like this:
// Place your settings in this file to overwrite the default settings
{
// Snip... other configurations overrides
// Points to the PHP executable.
// Use the version-agnostic value from the "whereis php" command above.
"php.validate.executablePath": "/usr/bin/php"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With