linux xammp Visual Studio Code 配置

Fed*_*man 6 php linux xampp configuration visual-studio-code

我想配置 Visual Studio Code (VSC) 以在 linux (Ubuntu) 上使用 php。

我为此安装了 xammp,但我不知道在 VSC php.validate.executablePath上将此参数指向何处

在 Windows 上,配置路径必须是这样的: "php.validate.executablePath": "c:/php/php.exe"

你能给我在LINUX 上正确配置它的完整路径吗?

问候

Fox*_*_64 7

这个答案可能会根据您使用的 Linux/Unix 风格而改变,但如果您像我一样使用 Ubuntu,我就是这样做的。

首先,我知道您正在使用 XAMPP,但请按照错误消息的说明进行操作并安装 PHP7。您可以通过运行来实现sudo apt-get install php

我知道这违背直觉。起初我想“我安装了XAMPP,它安装了PHP。为什么我需要安装PHP?” XAMPP 仅包含 PHP 运行时可执行文件。为了使用 PHP 进行开发,您需要安装完整的环境。XAMPP 将继续使用其内置版本。

安装完成后,请按照以下步骤操作:

  1. 执行whereis php。下面的示例输出:

    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. 在 Visual Studio Code 中,单击左下角的齿轮并选择设置。在右侧窗格中,插入以下代码。此处使用与版本无关的路径:

    "php.validate.executablePath": "/usr/bin/php"

  3. Control+S或单击文件 -> 保存

最终设置文件应如下所示:

// 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"
}
Run Code Online (Sandbox Code Playgroud)