Error installing php-di on slim 4.8

error that appears.

Problem 1
- php-di/php-di[6.3.0, …, 6.3.3] require psr/container ^1.0 → found psr/container[1.0.0, 1.1.0, 1.1.1] but the package is fixed to 2.0.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires php-di/php-di ^6.3 → satisfiable by php-di/php-di[6.3.0, 6.3.1, 6.3.2, 6.3.3].

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

1 Like

thanks it worked correctly for me

Today I had the same error message.
To fix this error, run: composer require php-di/php-di --with-all-dependencies

The cause of this error is Slim requiring either PSR/Container 1.x or 2.x, but PHP-DI only works with version 1. When you first install the Slim package, it will install version 2.x of the Container package. It still works fine with 1.x, so you can let composer downgrade the currently installed Container package from 2.x to 1.x. This is what the --with-all-dependencies switch does.