Abou Yaziyd
Abou Yaziyd

Reputation: 585

I am trying to update PHP Composer, but a problem arises

From the command line, I issue:

composer install

Output

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.

And:

composer update

Output

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.

How can I fix this?

Upvotes: 6

Views: 58601

Answers (5)

Kamafeather
Kamafeather

Reputation: 9835

Only in this specific case

you can ignore the platform requirement, with:

composer update --ignore-platform-reqs

This will ignore whether PHP version or PHP extensions version are installed correctly according to the requirements from the Composer dependencies.

This will make the app go through with the installation, and you might get the code working.

However: this solution is wrong! It was misleadingly marked as the best answer.

Beware

this solution is (temporarily) acceptable only because in this specific case the composer dependency's requirement is obviously too strict.

The PHP version requirement were written without considering future PHP versions (although their code would probably still compatible).
They specified a requirement of PHP semversion ~7.1 and ^7; that will not consider major versions like 8.x This was an oversight of the library author, hence it is acceptable to skip the platform requirements, to compensate for the issue!

Real solutions:

Any other case would probably need to either:

  • fix the composer.json using the correct dependencies (usually it's enough to do composer update or remove the specific version lock)
  • fix the system/OS by installing the missing extensions (if these are required rather than suggested)
  • report the issue to the author of the dependency that causes the error, telling them to provide a composer.json that keeps in account new versions of PHP (it would be sufficient to change fro caret to greater-than, with "php": ">=7".

Upvotes: 0

Abou Yaziyd
Abou Yaziyd

Reputation: 585

I used this command line and all of a sudden things happened like magic!

composer update --ignore-platform-reqs

Note: this is not always an acceptable solution!
Check @Kamafeather's answer below.

Upvotes: 38

OneKe
OneKe

Reputation: 137

Solution is, going to root folder of PHP (probably in C:\Program Files\php or inside xampp\php) and search for php.ini file. Inside this file, find out the commented line ";extension=fileinfo" and delete the ";" so it gets uncommented ad save the file. That was the problem for me. Really dumb, but apparently no one fixes it by default.

Upvotes: 0

Chaminda Chanaka
Chaminda Chanaka

Reputation: 190

when you try as a very first time please use --ignore-platform-reqs. this error occured due to your php version mismatching problems. then please use

composer install --ignore-platform-reqs

Happy coding!

Upvotes: 0

Luka
Luka

Reputation: 57

I had a similar problem, giving off a similar message:

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

What I did here is that I opened the php configuration file (php.ini) located in the folder that path points to in the error message (C:\xampp\php\php.ini in your case), checked if the named extensions were commented (had ; in front).

I commented the needed ones out, and then checked if the extensions directory looked for extensions in the right folder (Most of the time it should be extension_dir = "ext"). In my case, this was commented, so the program didn't really know from where the extensions were to be loaded. Uncommenting that line solved the problem for me.

Upvotes: 0

Related Questions