无法在Phpstorm中为编写器添加命令行工具支持


Unable to add command line tool support for the composer in Phpstorm

我在Windows 10上使用PHPStorm, WAMP服务器上使用php.exe,我已经安装了composer,使用ComposerSetup.exe用于Windows。我试图在Phpstorm中为作曲家添加命令行工具支持,但它失败并给出此错误。

问题未能将输出解析为XML:第2行错误:prolog中不允许有内容。<<em>命令/em>php.exe C:'ProgramData' composer setup 'bin'composer list——xml<<em>输出/em>

dir=$(d=$(dirname "$0"); cd "$d" && pwd)
# see if we are running in cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
    # cygwin paths start with /cygdrive/ which will break windows PHP,
    # so we need to translate the dir path to windows format. However
    # we could be using cygwin PHP which does not require this, so we
    # test if the path to PHP starts with /cygdrive/ rather than /usr/bin.
    if [[ $(which php) == /cygdrive/* ]]; then
        dir=$(cygpath -m $dir);
    fi
fi
dir=$(echo $dir | sed 's/ /' /g')
php "${dir}/composer.phar" $*

PHPStorm应该知道本地安装的PHP,它所需要的只是包含Composer PHP源代码的composer.phar文件。

你给PHPStorm看起来像一个Windows批处理文件,它检测在Windows shell中被调用的某些方面(如CMD vs. Cygwin),然后用composer.phar的路径调用PHP。这不是PHP的源代码,你可以直接给PHP,像PHPStorm。

只配置PHPStorm中phar文件的路径,不配置那个批处理文件的路径

或者,你可以简单地通过PHPStorm GUI添加Composer -如果它不知道,它应该要求你提供Composer,并且应该提供下载的可能性。

在他们的网站上有一个广泛的帮助文本,只需搜索"phpstorm install composer":https://www.jetbrains.com/phpstorm/help/using-composer-dependency-manager.html