即使安装了正确的php版本,为什么我在作曲家安装期间为过时的php版本获得版本不匹配?

时间:2018-01-04 17:34:12

标签: php composer-php php-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

我还检查了作曲家脚本,它定义了:

$ 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 个答案:

答案 0 :(得分:2)

检查您的作曲家配置,您已覆盖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

它对构建机器很有用,因此作曲家可以在运行不同php版本的机器上安装依赖项。但它不应该坚持我的开发机器。

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

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

在较新的作曲家版本上,配置托架成为:

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

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

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

答案 1 :(得分:1)

作为一个新项目的一部分,我进行了git checkout,然后进行了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.lock文件。如果有人知道但几次遇到这样的事件却很困惑,这是合乎逻辑的。