Development
Resolving Magento 2 Composer Dependency Conflicts Without Breaking Your Store
Magento's composer.json sits at the center of a large, tightly interdependent package graph — dozens of magento/module-* packages, a pinned PHP platform version, and however many third-party extensions you've layered on top. A single conflicting requirement can block an install entirely.
Read the Conflict Message Properly
Composer's conflict output is more useful than it looks at first glance — it names the exact packages and version constraints that can't coexist. Before trying anything, ask Composer directly why a package can't be at the version you want:
composer why-not magento/module-catalog 2.4.7This tells you exactly which installed package is holding the older version in place, instead of you guessing.
Always Dry-Run First
Before requiring a new package on a real environment, check what it would actually change:
composer require vendor/package:^2.0 --dry-runIf the dry run shows it wanting to downgrade Magento core modules or your PHP platform requirement, stop there — that's Composer telling you the new package isn't actually compatible with your current Magento version, not a bug in Composer.
Check Your Platform Config Matches Reality
A common source of confusing conflicts: composer.json's platform.php doesn't match the PHP version you're actually running, so Composer resolves dependencies for a PHP version you don't have.
composer show platform{
"config": {
"platform": {
"php": "8.3.0"
}
}
}Keep this in sync with your real PHP version — otherwise Composer can happily install a package that requires a PHP feature your actual runtime doesn't have.
Avoid Blanket composer update
Running composer update with no arguments re-resolves your entire dependency tree, which on a large Magento install can pull in dozens of unrelated version bumps at once — making it much harder to tell which change actually broke something if things go wrong.
Update just the package (and its direct dependents) you actually need to change:
composer update vendor/package --with-dependenciesClear Composer's Cache When Resolution Seems Wrong
If Composer keeps proposing a resolution that doesn't match what you'd expect from the constraints (or errors in ways that don't make sense given your composer.json), a stale cache is a common, easy-to-overlook cause:
composer clear-cachePin Third-Party Extension Versions Deliberately
Loose version constraints (^2.0 on a vendor extension you don't control) mean a composer update months from now can silently pull in a major version you never tested. For anything business-critical, pin to an exact tested version and bump it deliberately:
{
"require": {
"vendor/extension": "2.3.1"
}
}Test Composer Changes Somewhere Disposable First
Dependency changes are exactly the kind of thing you don't want to debug live — a throwaway environment where a broken composer update costs you nothing but a few minutes is the safest place to work through a conflict before it ever touches production.
Quick Reference
composer why-not magento/module-catalog 2.4.7
composer require vendor/package:^2.0 --dry-run
composer show platform
composer update vendor/package --with-dependencies
composer clear-cacheWork through conflicts in that order — most of the time, why-not and a dry run together will tell you exactly what's actually blocking you, before you touch a single version number.