简体   繁体   English

在 PHPStorm 中配置远程 (WSL) Composer

[英]Configuring Remote (WSL) Composer in PHPStorm

I'm trying to configure a PHPStorm project to utilize both remote PHP and a remote Composer.我正在尝试配置一个 PHPStorm 项目以利用远程 PHP 和远程 Composer。 Remote being my Windows Subsystem for Linux (WSL) installation.远程是我用于 Linux (WSL) 安装的 Windows 子系统。 However, when I initiate any Composer commands from PHPStorm, I get errors.但是,当我从 PHPStorm 启动任何 Composer 命令时,都会出现错误。 And unfortunately, the errors are not very indicative of the cause or offer a link for additional details.不幸的是,这些错误并不能很好地说明原因,也不能提供更多详细信息的链接。

Errors received in my "Event Log":我的“事件日志”中收到的错误:

12:21 PM    Composer
Failed to install packages for  ./composer.json.
Show in Log

And in my "Composer Log":在我的“作曲家日志”中:

install --no-interaction --no-ansi
/bin/sh: 1: composer: not found
Failed to install packages for  ./composer.json.

So far, I've followed the instructions located at:到目前为止,我已按照以下说明进行操作:

https://www.jetbrains.com/help/phpstorm/how-to-use-wsl-development-environment-in-product.html https://www.jetbrains.com/help/phpstorm/how-to-use-wsl-development-environment-in-product.html

https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html

I also followed the answer at this post to set WSL as my default terminal:我还按照这篇文章的答案将 WSL 设置为我的默认终端:

How to use WSL as default terminal in WebStorm or any other JetBrains' products? 如何在 WebStorm 或任何其他 JetBrains 产品中使用 WSL 作为默认终端?

In my WSL installation, composer is located at /home/<user>/.local/bin/composer and is included in my path upon login in my /home/<user>/.profile file.在我的 WSL 安装中,composer 位于/home/<user>/.local/bin/composer并在登录我的/home/<user>/.profile文件时包含在我的路径中。 And I was sure to restart PHPStorm after doing so to ensure it has the updated path.这样做后我肯定会重新启动 PHPStorm 以确保它具有更新的路径。 Additionally, running composer install within my project, on WSL works without issue.此外,在我的项目中运行composer install在 WSL 上运行没有问题。

I'm not sure how to determine which terminal or composer file PHPStorm is using.我不确定如何确定 PHPStorm 正在使用哪个终端或作曲家文件。 Either it's still trying to find and use a composer on my host Windows install (which doesn't exist) or I'm missing a path which I have to map for WSL.要么它仍在尝试在我的主机 Windows 安装(不存在)上查找和使用作曲家,要么我缺少一条路径,我必须为 WSL 安装 map。

Any idea how I can obtain more details as to what I have misconfigured?知道如何获得有关我配置错误的更多详细信息吗?

I figured out my issue.我想出了我的问题。

When in Settings -> PHP -> Composer, in the "Execution" section.在设置 -> PHP -> Composer 中,在“执行”部分。 I was already selecting "Remote Interpreter", but the "Composer executable" field requires an absolute path.我已经选择了“Remote Interpreter”,但“Composer executable”字段需要绝对路径。 I was simply supplying the name of the executable since the field is asking for the executable.我只是提供了可执行文件的名称,因为该字段要求提供可执行文件。

I just figured it would utilize my $PATH to resolve the executable, but this isn't using an SSH session so it wouldn't have my custom $PATH values.我只是想它会利用我的 $PATH 来解析可执行文件,但这不是使用 SSH session 所以它不会有我的自定义 $PATH 值。 So it all makes sense.所以这一切都说得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM