Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux xammp Visual Studio Code configuration

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

like image 741
Federico Traiman Avatar asked Dec 07 '16 01:12

Federico Traiman


1 Answers

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:

  1. 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

  2. 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"

  3. 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"
}
like image 173
Foxtrek_64 Avatar answered Oct 12 '22 23:10

Foxtrek_64