代码之家  ›  专栏  ›  技术社区  ›  k0pernikus

为什么在composer安装过程中,即使安装了正确的php版本,也会出现版本不匹配的问题?

  •  5
  • k0pernikus  · 技术社区  · 7 年前

    考虑到基础 composer.json :

    {
      "name": "kopernikus/fizzbuzz",
      "description": "FizzBuzz!",
      "type": "project",
      "require": {
        "php": "^7.0"
      },
      "require-dev": {
        "phpunit/phpunit": "^6.5"
      },
      "license": "MIT",
      "authors": [
        {
          "name": "Philipp Kretzschmar",
          "email": "philipp.kretzschmar@gmail.com"
        }
      ]
    }
    

    如果我运行:

    $ composer install
    

    我得到:

    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - This package requires php ^7.0 but your PHP version (5.5) does not satisfy that requirement.
      Problem 2
        - phpunit/phpunit 5.7.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.26 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.25 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.24 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.23 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.22 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.21 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.20 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.19 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.18 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.17 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.16 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.14 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.13 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.12 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.11 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.10 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.7.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.6.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.5.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.5.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.5.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
        - phpunit/phpunit 5.5.4 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.5.3 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.5.2 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.5.1 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.5.0 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.8 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.7 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.6 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.5 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.4 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.3 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.2 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.1 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.4.0 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.5 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.4 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.3 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.2 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.1 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.3.0 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.9 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.8 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.7 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.6 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.5 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.4 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.3 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.2 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.12 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.11 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.10 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.1 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.2.0 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.7 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.6 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.5 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.4 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.3 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.2 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.1 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.1.0 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.9 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.8 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.7 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.6 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.5 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.4 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.3 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.2 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.10 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.1 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.0.0 requires php >=5.6 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - phpunit/phpunit 5.5.4 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
        - Installation request for phpunit/phpunit ^5 -> satisfiable by phpunit/phpunit[5.0.0, 5.0.1, 5.0.10, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.2.0, 5.2.1, 5.2.10, 5.2.11, 5.2.12, 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 5.2.7, 5.2.8, 5.2.9, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4, 5.3.5, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.4.4, 5.4.5, 5.4.6, 5.4.7, 5.4.8, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.6.5, 5.6.6, 5.6.7, 5.6.8, 5.7.0, 5.7.1, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14, 5.7.15, 5.7.16, 5.7.17, 5.7.18, 5.7.19, 5.7.2, 5.7.20, 5.7.21, 5.7.22, 5.7.23, 5.7.24, 5.7.25, 5.7.26, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.7, 5.7.8, 5.7.9].
    
      To enable extensions, verify that they are enabled in your .ini files:
        - /etc/php/7.0/cli/php.ini
        - /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
        - /etc/php/7.0/cli/conf.d/10-opcache.ini
        - /etc/php/7.0/cli/conf.d/10-pdo.ini
        - /etc/php/7.0/cli/conf.d/15-xml.ini
        - /etc/php/7.0/cli/conf.d/20-apcu.ini
        - /etc/php/7.0/cli/conf.d/20-apcu_bc.ini
        - /etc/php/7.0/cli/conf.d/20-calendar.ini
        - /etc/php/7.0/cli/conf.d/20-ctype.ini
        - /etc/php/7.0/cli/conf.d/20-curl.ini
        - /etc/php/7.0/cli/conf.d/20-dom.ini
        - /etc/php/7.0/cli/conf.d/20-exif.ini
        - /etc/php/7.0/cli/conf.d/20-fileinfo.ini
        - /etc/php/7.0/cli/conf.d/20-ftp.ini
        - /etc/php/7.0/cli/conf.d/20-gettext.ini
        - /etc/php/7.0/cli/conf.d/20-iconv.ini
        - /etc/php/7.0/cli/conf.d/20-intl.ini
        - /etc/php/7.0/cli/conf.d/20-json.ini
        - /etc/php/7.0/cli/conf.d/20-mongodb.ini
        - /etc/php/7.0/cli/conf.d/20-mysqli.ini
        - /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
        - /etc/php/7.0/cli/conf.d/20-phar.ini
        - /etc/php/7.0/cli/conf.d/20-posix.ini
        - /etc/php/7.0/cli/conf.d/20-readline.ini
        - /etc/php/7.0/cli/conf.d/20-shmop.ini
        - /etc/php/7.0/cli/conf.d/20-simplexml.ini
        - /etc/php/7.0/cli/conf.d/20-sockets.ini
        - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
        - /etc/php/7.0/cli/conf.d/20-sysvsem.ini
        - /etc/php/7.0/cli/conf.d/20-sysvshm.ini
        - /etc/php/7.0/cli/conf.d/20-tokenizer.ini
        - /etc/php/7.0/cli/conf.d/20-wddx.ini
        - /etc/php/7.0/cli/conf.d/20-xmlreader.ini
        - /etc/php/7.0/cli/conf.d/20-xmlwriter.ini
        - /etc/php/7.0/cli/conf.d/20-xsl.ini
    

    我很困惑,因为:

    php -v
    PHP 7.0.26-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec  7 2017 20:09:40) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.0.26-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies
    

    我还检查了composer脚本,它定义了:

    $ which composer
    /usr/local/bin/composer
    
    $ head -n 1 /usr/local/bin/composer
    #!/usr/bin/env php
    
    $ /usr/bin/env php
    PHP 7.0.26-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec  7 2017 20:09:40) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.0.26-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies
    

    即使 diagnose 无需报警:

    $ composer diagnose
    Checking composer.json: OK
    Checking platform settings: OK
    Checking git settings: OK
    Checking http connectivity to packagist: OK
    Checking https connectivity to packagist: OK
    Checking github.com rate limit: OK
    Checking disk free space: OK
    Checking pubkeys: 
    Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
    Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
    OK
    Checking composer version: OK
    Composer version: 1.6.1
    PHP version: 7.0.26-2+ubuntu16.04.1+deb.sury.org+2
    PHP binary path: /usr/bin/php7.0
    

    为什么作曲家认为我在跑步php@5.5即使我只有php@7安装?

    2 回复  |  直到 7 年前
        1
  •  5
  •   k0pernikus    7 年前

    检查作曲家配置,您已覆盖 platform 设置。

    这在日志行中变得明显:

       - phpunit/phpunit 5.5.4 requires php ^5.6 || ^7.0 -> your PHP version (7.0.26-2+ubuntu16.04.1+deb.sury.org+2) overridden by "config.platform.php" version (5.5) does not satisfy that requirement.
    

    重要的一点是:

    your PHP version (7...) overridden by "config.platform.php" version (5.5)
    

    此外,您还可以查看是否通过以下方式进行设置:

    $ composer config platform.php
    5.5
    

    它对于构建机器非常有用,以便composer可以在运行不同php版本的机器上安装依赖项。然而,它不应该一直存在于我的开发机器上。

    我在过去将平台设置为5.5,以便仍然能够 composer install php7下的php5项目 composer install --ignore-platform-reqs 就足够了,或者也可以在项目级别设置平台配置。但我在全局配置中有:

    $ jq . ~/.composer/config.json 
    {
      "config": {
        "platform": {
          "php": "5.5"
        }
      }
    }
    

    在较新的composer版本中,配置托架是:

    jq . ~/.config/composer/composer.json 
    {
      "require": {
        "hirak/prestissimo": "^0.3.7"
      },
      "config": {
        "platform": {
          "php": "5.5"
        }
      }
    }
    

    我也可能存在于您项目的 composer.json .

    我必须删除平台配置 不得不 composer update 项目的 composer.lock 也仅删除配置是不够的。

        2
  •  1
  •   Clemens Tolboom    5 年前

    作为一个新项目的一部分,我当时进行了git签出 composer install 这给了我所提到的错误。我的是

    composer install
    
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - This package requires php >=7.1.0 but your PHP version (7.0.18; Package overridden via config.platform (actual: 7.2.21)) does not satisfy that requirement.
    ...
    

    这是一个同事登记的 composer.lock 具有以下内容的文件

        "platform-overrides": {
            "php": "7.0.18"
    

    原因

    执行时 composer install composer使用 创作者锁 仅文件。这是合乎逻辑的,如果你知道,但非常混乱的几次遇到这样的事件。