我正在尝试更新 PHP Composer,但出现了问题

问题描述 投票:0回答:5

从命令行,我发出:

composer install

输出

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - doctrine/cache is locked to version v1.8.0 and an update of this package was not requested.
    - doctrine/cache v1.8.0 requires php ~7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 2
    - doctrine/dbal is locked to version v2.9.2 and an update of this package was not requested.
    - doctrine/dbal v2.9.2 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 3
    - doctrine/event-manager is locked to version v1.0.0 and an update of this package was not requested.
    - doctrine/event-manager v1.0.0 requires php ^7.1 -> your php version (8.0.0) does not satisfy that
requirement.
  Problem 4
    - doctrine/inflector is locked to version v1.3.0 and an update of this package was not requested.
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 5
    - maatwebsite/excel is locked to version 3.1.13 and an update of this package was not requested.
    - maatwebsite/excel 3.1.13 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 6
    - markbaker/complex is locked to version 1.4.7 and an update of this package was not requested.
    - markbaker/complex 1.4.7 requires php ^5.6.0|^7.0.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 7
    - markbaker/matrix is locked to version 1.1.4 and an update of this package was not requested.
    - markbaker/matrix 1.1.4 requires php ^5.6.0|^7.0.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 8
    - opis/closure is locked to version 3.2.0 and an update of this package was not requested.
    - opis/closure 3.2.0 requires php ^5.4 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 9
    - phpoffice/phpspreadsheet is locked to version 1.6.0 and an update of this package was not requested.
    - phpoffice/phpspreadsheet 1.6.0 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.
  Problem 10
    - ramsey/uuid is locked to version 3.8.0 and an update of this package was not requested.
    - ramsey/uuid 3.8.0 requires php ^5.4 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 11
    - renatomarinho/laravel-page-speed is locked to version 1.8.10 and an update of this package was not requested.
    - renatomarinho/laravel-page-speed 1.8.10 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 12
    - symfony/psr-http-message-bridge is locked to version v1.2.0 and an update of this package was not
requested.
    - symfony/psr-http-message-bridge v1.2.0 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 13
    - tijsverkoyen/css-to-inline-styles is locked to version 2.2.1 and an update of this package was not requested.
    - tijsverkoyen/css-to-inline-styles 2.2.1 requires php ^5.5 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 14
    - zendframework/zend-diactoros is locked to version 1.8.6 and an update of this package was not requested.
    - zendframework/zend-diactoros 1.8.6 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not
satisfy that requirement.
  Problem 15
    - composer/semver is locked to version 1.5.0 and an update of this package was not requested.
    - composer/semver 1.5.0 requires php ^5.3.2 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 16
    - composer/xdebug-handler is locked to version 1.3.2 and an update of this package was not requested.
    - composer/xdebug-handler 1.3.2 requires php ^5.3.2 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 17
    - doctrine/annotations is locked to version v1.6.1 and an update of this package was not requested.
    - doctrine/annotations v1.6.1 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 18
    - doctrine/instantiator is locked to version 1.2.0 and an update of this package was not requested.
    - doctrine/instantiator 1.2.0 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 19
    - facebook/webdriver is locked to version 1.6.0 and an update of this package was not requested.
    - facebook/webdriver 1.6.0 requires php ^5.6 || ~7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 20
    - filp/whoops is locked to version 2.3.1 and an update of this package was not requested.
    - filp/whoops 2.3.1 requires php ^5.5.9 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 21
    - friendsofphp/php-cs-fixer is locked to version v2.15.0 and an update of this package was not requested.
    - friendsofphp/php-cs-fixer v2.15.0 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 22
    - fzaninotto/faker is locked to version v1.8.0 and an update of this package was not requested.
    - fzaninotto/faker v1.8.0 requires php ^5.3.3 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 23
    - hamcrest/hamcrest-php is locked to version v2.0.0 and an update of this package was not requested.    - hamcrest/hamcrest-php v2.0.0 requires php ^5.3|^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 24
    - myclabs/deep-copy is locked to version 1.9.1 and an update of this package was not requested.
    - myclabs/deep-copy 1.9.1 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 25
    - phar-io/manifest is locked to version 1.0.1 and an update of this package was not requested.
    - phar-io/manifest 1.0.1 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 26
    - phar-io/version is locked to version 1.0.1 and an update of this package was not requested.
    - phar-io/version 1.0.1 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that
requirement.
  Problem 27
    - php-cs-fixer/diff is locked to version v1.3.0 and an update of this package was not requested.
    - php-cs-fixer/diff v1.3.0 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 28
    - phpdocumentor/reflection-docblock is locked to version 4.3.1 and an update of this package was not requested.
    - phpdocumentor/reflection-docblock 4.3.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 29
    - phpdocumentor/type-resolver is locked to version 0.4.0 and an update of this package was not requested.
    - phpdocumentor/type-resolver 0.4.0 requires php ^5.5 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 30
    - phpspec/prophecy is locked to version 1.8.0 and an update of this package was not requested.
    - phpspec/prophecy 1.8.0 requires php ^5.3|^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 31
    - phpunit/php-code-coverage is locked to version 5.3.2 and an update of this package was not requested.
    - phpunit/php-code-coverage 5.3.2 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 32
    - phpunit/php-timer is locked to version 1.0.9 and an update of this package was not requested.
    - phpunit/php-timer 1.0.9 requires php ^5.3.3 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 33
    - phpunit/php-token-stream is locked to version 2.0.2 and an update of this package was not requested.
    - phpunit/php-token-stream 2.0.2 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 34
    - phpunit/phpunit is locked to version 6.5.14 and an update of this package was not requested.
    - phpunit/phpunit 6.5.14 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 35
    - phpunit/phpunit-mock-objects is locked to version 5.0.10 and an update of this package was not requested.
    - phpunit/phpunit-mock-objects 5.0.10 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 36
    - sebastian/code-unit-reverse-lookup is locked to version 1.0.1 and an update of this package was not requested.
    - sebastian/code-unit-reverse-lookup 1.0.1 requires php ^5.6 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 37
    - sebastian/comparator is locked to version 2.1.3 and an update of this package was not requested.
    - sebastian/comparator 2.1.3 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 38
    - sebastian/diff is locked to version 2.0.1 and an update of this package was not requested.
    - sebastian/diff 2.0.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 39
    - sebastian/environment is locked to version 3.1.0 and an update of this package was not requested.
    - sebastian/environment 3.1.0 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 40
    - sebastian/exporter is locked to version 3.1.0 and an update of this package was not requested.
    - sebastian/exporter 3.1.0 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 41
    - sebastian/global-state is locked to version 2.0.0 and an update of this package was not requested.    - sebastian/global-state 2.0.0 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 42
    - sebastian/object-enumerator is locked to version 3.0.3 and an update of this package was not requested.
    - sebastian/object-enumerator 3.0.3 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 43
    - sebastian/object-reflector is locked to version 1.1.1 and an update of this package was not requested.
    - sebastian/object-reflector 1.1.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 44
    - sebastian/recursion-context is locked to version 3.0.0 and an update of this package was not requested.
    - sebastian/recursion-context 3.0.0 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 45
    - theseer/tokenizer is locked to version 1.1.2 and an update of this package was not requested.
    - theseer/tokenizer 1.1.2 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
  Problem 46
    - webmozart/assert is locked to version 1.4.0 and an update of this package was not requested.
    - webmozart/assert 1.4.0 requires php ^5.3.3 || ^7.0 -> your php version (8.0.0) does not satisfy th  Problem 47
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
    - laravel/framework v5.5.45 requires doctrine/inflector ~1.1 -> satisfiable by doctrine/inflector[v1.3.0].
    - laravel/framework is locked to version v5.5.45 and an update of this package was not requested.

To enable extensions, verify that they are enabled in your .ini files:
    - C:\xampp\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

并且:

composer update

输出

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - maatwebsite/excel 3.1.26 requires phpoffice/phpspreadsheet ^1.15 -> satisfiable by phpoffice/phpspreadsheet[1.15.0, 1.16.0].
    - maatwebsite/excel[3.1.0, ..., 3.1.25] require php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
    - phpoffice/phpspreadsheet[1.15.0, ..., 1.16.0] require ext-gd * -> it is missing from your system.
Install or enable PHP's gd extension.
    - Root composer.json requires maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, ..., 3.1.26].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\xampp\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

我该如何解决这个问题?

php composer-php
5个回答
37
投票

我使用了这个命令行,突然事情就像魔法一样发生了!

composer update --ignore-platform-reqs

注意:这并不总是可接受的解决方案!
检查下面@Kamafeather的回答


0
投票

我遇到了类似的问题,发出了类似的消息:

Problem 1
- laminas/laminas-i18n[2.11.0, ..., 2.11.3] require php ^7.3 || ~8.0.0 -> your php version (8.1.10) does not satisfy that requirement.
- laminas/laminas-i18n[2.12.0, ..., 2.18.0] require ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
- laminas/laminas-mvc-form 2.0.0 requires laminas/laminas-i18n ^2.11.2 -> satisfiable by laminas/laminas-i18n[2.11.2, ..., 2.18.0].
- Root composer.json requires laminas/laminas-mvc-form ^2.0.0 -> satisfiable by laminas/laminas-mvc-form[2.0.0].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\php\php-8.1.10-nts-Win32-vs16-x64\php.ini

我在这里所做的是,我打开了位于错误消息中路径指向的文件夹中的 php 配置文件 (php.ini)(在您的情况下为 C:\xampp\php\php.ini),检查命名是否为扩展已被注释(前面有 ;)。

我将需要的注释掉,然后检查扩展目录是否在正确的文件夹中查找扩展(大多数情况下应该是extension_dir =“ext”)。就我而言,这是注释的,因此程序并不真正知道从哪里加载扩展。取消注释该行解决了我的问题。


0
投票

当您第一次尝试时,请使用 --ignore-platform-reqs。 出现此错误是由于您的 php 版本不匹配问题。那么请使用

composer install --ignore-platform-reqs

编码快乐!


0
投票

解决方案是,转到 PHP 的根文件夹(可能在 C:\Program Files\php 或 xampp\php 中)并搜索 php.ini 文件。在该文件中,找到注释行“;extension=fileinfo”并删除“;”所以它会被取消注释并保存文件。 这对我来说就是问题。 真的很愚蠢,但显然没有人默认修复它。


0
投票

仅在这种特定情况下

您可以忽略平台要求,使用:

composer update --ignore-platform-reqs

当心

这是可以接受的,只是因为在这种特定情况下作曲家依赖项的要求显然太严格了。

考虑一下:

在 SemVer 中,插入符号 (^) 允许进行不更改版本字符串中最左边的非零数字的更新。对于 ^7.x.x,这意味着它将匹配从 7.0.0 到(但不包括)8.0.0 的任何版本。

因此,编写 PHP 版本要求时没有考虑未来的 PHP 版本(尽管它们可能仍然兼容)。
这是库作者的疏忽,因此跳过平台要求以弥补该问题是可以接受的! 任何其他情况可能需要:

修复
    composer.json
  • 通过安装缺少的扩展来修复系统/操作系统(如果这些是
  • 必需
  • 而不是建议 向导致错误的依赖项的作者报告问题,告诉他们提供一个
  • composer.json
  • 来记录 PHP 的新版本(将
    caret
    更改为 greater-than 就足够了,使用"php": ">=7"
        
© www.soinside.com 2019 - 2024. All rights reserved.