Composer not recognizing php 5.6.4 [duplicate]

烈酒焚心 提交于 2019-12-12 03:47:26

问题


I have added PHP 5.6.4 to Wamp and it works correctly, the icon is green and able to view my sites on localhost.

As part of our project I need to have Composer working with one of our plugins. When I try to install Composer using GitBash I receive this error.

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].

Problem 5 states I do not satisfy the required version of PHP. What do I need to get Composer to find the version I need.

Here is my 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/"
        }
    }
}

回答1:


The problem is that composer uses that php binary which was specified during composer installation, and not the WAMP one. Several solutions:

Overwrite the alias for composer (or php) in git bash

Add this to your ~/.bashrc or ~/.bash_profile in git bash:

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

Make git bash use the specified PHP version

Add this to your ~/.bashrc or ~/.bash_profile in git 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

Add the path to WAMP's php into Windows environment variables

Add the path to PHP binary to the PATH variable. E.g.:

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

See this and this questions for more info.



来源:https://stackoverflow.com/questions/40478663/composer-not-recognizing-php-5-6-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!