【问题标题】:linux xammp Visual Studio Code configurationlinux xampp Visual Studio 代码配置
【发布时间】:2017-04-21 20:21:56
【问题描述】:

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

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

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

您能否给我正确配置它的完整路径ON LINUX

问候

【问题讨论】:

  • 我们怎么知道你在什么路径下安装了xammp
  • 如果您使用标准软件包简单地安装这些组件(http 服务器、mysql 数据库系统、php 语言),我们可以提供帮助。但如果您按照xammp 的要求进行狂野安装,则不会。
  • 我的错。我做了一个常规的xammp安装,所以我电脑上的xammp路径是/opt/lampp
  • “常规 xammp 安装”绕过系统软件管理系统。这是一个具有所有含义的“狂野安装”。为什么要这样做?
  • 我在我的电脑上使用xammp作为沙盒,这就是我选择它的原因。你能给我 Visual Studio 代码 json 配置文件的 php 路径吗?

标签: php linux configuration xampp visual-studio-code


【解决方案1】:

这个答案可能会根据你使用的 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"
}

【讨论】:

    【解决方案2】:

    对我来说是“/opt/lampp/bin/php”(我在 Linux Mint 上有 xampp;找出在终端中写入:“whereis php”)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-06
      • 2019-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-06
      • 2019-10-29
      相关资源
      最近更新 更多