作曲家无法识别 php 5.6.4

Composer not recognizing php 5.6.4

我已将 PHP 5.6.4 添加到 Wamp 并且它工作正常,图标为绿色并且能够在本地主机上查看我的站点。

作为我们项目的一部分,我需要让 Composer 与我们的一个插件一起工作。当我尝试使用 GitBash 安装 Composer 时收到此错误。

composer install

  Problem 1
    - Installation request for illuminate/container v5.3.16 -> satisfiable by illuminate/container[v5.3.16].
    - illuminate/container v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.12) does not satisfy that requirement.
  Problem 2
    - Installation request for illuminate/contracts v5.3.16 -> satisfiable by illuminate/contracts[v5.3.16].
    - illuminate/contracts v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.12) does not satisfy that requirement.
  Problem 3
    - Installation request for illuminate/database v5.3.16 -> satisfiable by illuminate/database[v5.3.16].
    - illuminate/database v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.12) does not satisfy that requirement.
  Problem 4
    - Installation request for illuminate/support v5.3.16 -> satisfiable by illuminate/support[v5.3.16].
    - illuminate/support v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.12) does not satisfy that requirement.
  Problem 5
    - illuminate/database v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.12) does not satisfy that requirement.
    - devonblzx/wp-eloquent 5.3.x-dev requires illuminate/database 5.3.* -> satisfiable by illuminate/database[v5.3.16].
    - Installation request for devonblzx/wp-eloquent 5.3.x-dev -> satisfiable by devonblzx/wp-eloquent[5.3.x-dev].

问题 5 表明我不满足 PHP 的要求版本。我需要什么才能让 Composer 找到我需要的版本。

这是我的 composer.json

{
    "name": "tours",
    "description": "Tours Package",
    "license": "Closed Source",
    "require": {
        "tourcms/tourcms-php": "3.0.*",
        "devonblzx/wp-eloquent": "5.3.x-dev"
    },
    "require-dev": {
        "psy/psysh": "0.7.*"
    },
    "suggest": {
        "tightenco/collect": "If Illuminate Support is not included, this package is required for collection support in tourcms_base"
    },
    "autoload": {
        "psr-4": {
            "": "tourcms_base/src/",
            "Discover\": "",
            "GMaps\": "gmaps/"
        }
    }
}

问题是 composer 使用了在 composer 安装期间指定的 php 二进制文件,而不是 WAMP 二进制文件。几种解决方案:

在 git bash

中覆盖作曲家(或 php)的别名

将此添加到 git 中的 ~/.bashrc~/.bash_profile bash:

alias composer='path/to/php/binary composer.phar '

使gitbash使用指定的PHP版本

将此添加到 git 中的 ~/.bashrc~/.bash_profile bash:

# Use WAMP version of PHP
PHP_VERSION=`ls /path/to/wamp/bin/php/ | sort -n | tail -1`
export PATH=/path/to/wamp/bin/php/${PHP_VERSION}/bin:$PATH

将WAMP的php路径加入Windows环境变量

将 PHP 二进制文件的路径添加到 PATH 变量。例如:

;C:\wamp\bin\php\php5.6.4

有关详细信息,请参阅 this and this 个问题。