【问题标题】:Composer not recognizing php 5.6.4 [duplicate]Composer 无法识别 php 5.6.4 [重复]
【发布时间】:2016-11-08 03:52:50
【问题描述】:

我已将 PHP 5.6.4 添加到 Wamp,它可以正常工作,图标为绿色,可以在 localhost 上查看我的网站。

作为我们项目的一部分,我需要让 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/"
        }
    }
}

【问题讨论】:

    标签: php composer-php wamp


    【解决方案1】:

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

    在 git bash 中覆盖 composer(或 php)的别名

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

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

    让 git bash 使用指定的 PHP 版本

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

    # 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
    

    有关更多信息,请参阅thisthis 问题。

    【讨论】:

    • 谢谢。将 WAMP 的 php 路径编辑到 Windows 环境变量中对我有用。 C:\wamp\bin\php\php5.6.4
    猜你喜欢
    • 2021-02-26
    • 1970-01-01
    • 2013-09-17
    • 2018-07-21
    • 2019-03-14
    • 2011-04-27
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多