【问题标题】:Unable to add command line tool support for the composer in Phpstorm无法为 Phpstorm 中的作曲家添加命令行工具支持
【发布时间】:2015-10-21 16:22:28
【问题描述】:

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

问题 无法将输出解析为 XML:第 2 行错误:prolog 中不允许内容。 命令 php.exe C:\ProgramData\ComposerSetup\bin\composer 列表 --xml 输出

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" $*

【问题讨论】:

    标签: php composer-php phpstorm


    【解决方案1】:

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

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

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

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

    通过谷歌搜索“phpstorm install composer”即可在他们的网站上找到大量帮助文本:https://www.jetbrains.com/phpstorm/help/using-composer-dependency-manager.html

    【讨论】:

      猜你喜欢
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      • 2018-04-26
      • 2018-10-27
      • 2015-07-26
      • 2018-05-18
      • 2018-01-16
      • 2012-10-24
      相关资源
      最近更新 更多