title: How to resolve the Composer dependencies conflicts (a clean way)?
body: <p>I'm writing a PHP application based on Symfony <code>v5.0.11</code>. Now I want to upgrade Symfony to the <code>^v5.2</code>. (The Composer version is <code>2.0.12</code>.)</p>
  <pre><code>$ composer require symfony/framework-bundle:^5.2
  ./composer.json has been updated
  Running composer update symfony/framework-bundle
  Loading composer repositories with package information
  Updating dependencies
  Your requirements could not be resolved to an installable set of packages.
  
    Problem 1
      - symfony/framework-bundle[v5.2.0, ..., v5.2.6] require symfony/cache ^5.2 -&gt; found symfony/cache[v5.2.0, ..., v5.2.6] but the package is fixed to v5.0.11 (lock file version) by a partia
  l update and that version does not match. Make sure you list it as an argument for the update command.
      - Root composer.json requires symfony/framework-bundle ^5.2 -&gt; satisfiable by symfony/framework-bundle[v5.2.0, ..., v5.2.6].
  
  Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
  
  Installation failed, reverting ./composer.json and ./composer.lock to their original content.
  </code></pre>
  <p>It hasn't worked, because the <code>symfony/cache</code> package is locked to the <code>v5.0.11</code> version in <code>composer.lock</code>. But when I try using the <code>--with-all-dependencies</code> option, as suggested in the error message:</p>
  <pre><code>$ composer require --update-with-all-dependencies symfony/framework-bundle:^5.2
  ./composer.json has been updated
  Running composer update symfony/framework-bundle --with-all-dependencies
  Loading composer repositories with package information
  Restricting packages listed in &quot;symfony/symfony&quot; to &quot;5.0.*&quot;
  Updating dependencies
  Your requirements could not be resolved to an installable set of packages.
  
    Problem 1
      - symfony/framework-bundle[v5.2.0, ..., v5.2.6] require symfony/cache ^5.2 -&gt; found symfony/cache[v5.2.0, ..., v5.2.6] but these were not loaded, likely because it conflicts with another
   require.
      - Root composer.json requires symfony/framework-bundle ^5.2 -&gt; satisfiable by symfony/framework-bundle[v5.2.0, ..., v5.2.6].
  
  
  Installation failed, reverting ./composer.json and ./composer.lock to their original content.
  </code></pre>
  <p>Now the problem is, that Composer cannot install the needed version of the package <code>symfony/cache</code>, possibly &quot;<em>because it conflicts with another require</em>&quot;.</p>
  <p>How to solve these / such Composer issues cleanly? (&quot;Clean&quot; means here: without resetting the project, running the across-the-board <code>composer update</code>, or making other brutal stuff with unpredictable side-effects.)</p>
  <hr />
  <p><strong>UPDATE</strong></p>
  <ul>
  <li><code>composer.json</code></li>
  <li><code>composer.lock</code></li>
  <li><code>symfony.lock</code></li>
  </ul>
  <p><strong><code>composer.json</code></strong></p>
  <pre><code>{
      &quot;type&quot;: &quot;project&quot;,
      &quot;license&quot;: &quot;proprietary&quot;,
      &quot;require&quot;: {
          &quot;php&quot;: &quot;^7.3.0 || ^8.0.0&quot;,
          &quot;ext-ctype&quot;: &quot;*&quot;,
          &quot;ext-iconv&quot;: &quot;*&quot;,
          &quot;knplabs/knp-markdown-bundle&quot;: &quot;^1.9&quot;,
          &quot;paragonie/sodium_compat&quot;: &quot;^1.15&quot;,
          &quot;sensio/framework-extra-bundle&quot;: &quot;^6.0&quot;,
          &quot;sentry/sentry-symfony&quot;: &quot;^4.0&quot;,
          &quot;symfony/asset&quot;: &quot;5.0.*&quot;,
          &quot;symfony/console&quot;: &quot;5.0.*&quot;,
          &quot;symfony/debug-bundle&quot;: &quot;5.0.*&quot;,
          &quot;symfony/dotenv&quot;: &quot;5.0.*&quot;,
          &quot;symfony/flex&quot;: &quot;^1.3.1&quot;,
          &quot;symfony/framework-bundle&quot;: &quot;5.0.*&quot;,
          &quot;symfony/monolog-bundle&quot;: &quot;^3.0&quot;,
          &quot;symfony/profiler-pack&quot;: &quot;*&quot;,
          &quot;symfony/routing&quot;: &quot;5.1.*&quot;,
          &quot;symfony/twig-pack&quot;: &quot;^1.0&quot;,
          &quot;symfony/var-dumper&quot;: &quot;5.0.*&quot;,
          &quot;symfony/webpack-encore-bundle&quot;: &quot;^1.7&quot;,
          &quot;symfony/yaml&quot;: &quot;5.0.*&quot;
      },
      &quot;require-dev&quot;: {
          &quot;symfony/maker-bundle&quot;: &quot;^1.30&quot;,
          &quot;symfony/profiler-pack&quot;: &quot;^1.0&quot;
      },
      &quot;config&quot;: {
          &quot;preferred-install&quot;: {
              &quot;*&quot;: &quot;dist&quot;
          },
          &quot;sort-packages&quot;: true,
          &quot;platform&quot;: {}
      },
      &quot;autoload&quot;: {
          &quot;psr-4&quot;: {
              &quot;App\\&quot;: &quot;src/&quot;
          }
      },
      &quot;autoload-dev&quot;: {
          &quot;psr-4&quot;: {
              &quot;App\\Tests\\&quot;: &quot;tests/&quot;
          }
      },
      &quot;replace&quot;: {
          &quot;paragonie/random_compat&quot;: &quot;2.*&quot;,
          &quot;symfony/polyfill-ctype&quot;: &quot;*&quot;,
          &quot;symfony/polyfill-iconv&quot;: &quot;*&quot;,
          &quot;symfony/polyfill-php72&quot;: &quot;*&quot;,
          &quot;symfony/polyfill-php71&quot;: &quot;*&quot;,
          &quot;symfony/polyfill-php70&quot;: &quot;*&quot;,
          &quot;symfony/polyfill-php56&quot;: &quot;*&quot;
      },
      &quot;scripts&quot;: {
          &quot;auto-scripts&quot;: {
              &quot;cache:clear&quot;: &quot;symfony-cmd&quot;,
              &quot;assets:install %PUBLIC_DIR%&quot;: &quot;symfony-cmd&quot;
          },
          &quot;post-install-cmd&quot;: [
              &quot;@auto-scripts&quot;
          ],
          &quot;post-update-cmd&quot;: [
              &quot;@auto-scripts&quot;
          ]
      },
      &quot;conflict&quot;: {
          &quot;symfony/symfony&quot;: &quot;*&quot;
      },
      &quot;extra&quot;: {
          &quot;symfony&quot;: {
              &quot;allow-contrib&quot;: true,
              &quot;require&quot;: &quot;5.0.*&quot;
          }
      }
  }
  </code></pre>
  <p><strong><code>composer.lock</code></strong></p>
  <pre><code>{
      ...
          {
              &quot;name&quot;: &quot;symfony/framework-bundle&quot;,
              &quot;version&quot;: &quot;v5.0.11&quot;,
              &quot;source&quot;: {
                  &quot;type&quot;: &quot;git&quot;,
                  &quot;url&quot;: &quot;https://github.com/symfony/framework-bundle.git&quot;,
                  &quot;reference&quot;: &quot;0fc0a93f8bbe465d0b483e21b087d432baa92c16&quot;
              },
              &quot;dist&quot;: {
                  &quot;type&quot;: &quot;zip&quot;,
                  &quot;url&quot;: &quot;https://api.github.com/repos/symfony/framework-bundle/zipball/0fc0a93f8bbe465d0b483e21b087d432baa92c16&quot;,
                  &quot;reference&quot;: &quot;0fc0a93f8bbe465d0b483e21b087d432baa92c16&quot;,
                  &quot;shasum&quot;: &quot;&quot;
              },
              &quot;require&quot;: {
                  &quot;ext-xml&quot;: &quot;*&quot;,
                  &quot;php&quot;: &quot;&gt;=7.2.5&quot;,
                  &quot;symfony/cache&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/config&quot;: &quot;^5.0&quot;,
                  &quot;symfony/dependency-injection&quot;: &quot;^5.0.1&quot;,
                  &quot;symfony/error-handler&quot;: &quot;^4.4.1|^5.0.1&quot;,
                  &quot;symfony/filesystem&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/finder&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/http-foundation&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/http-kernel&quot;: &quot;^5.0&quot;,
                  &quot;symfony/polyfill-mbstring&quot;: &quot;~1.0&quot;,
                  &quot;symfony/routing&quot;: &quot;^5.0&quot;
              },
              &quot;conflict&quot;: {
                  &quot;doctrine/persistence&quot;: &quot;&lt;1.3&quot;,
                  &quot;phpdocumentor/reflection-docblock&quot;: &quot;&lt;3.0&quot;,
                  &quot;phpdocumentor/type-resolver&quot;: &quot;&lt;0.2.1&quot;,
                  &quot;phpunit/phpunit&quot;: &quot;&lt;5.4.3&quot;,
                  &quot;symfony/asset&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/browser-kit&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/console&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/dom-crawler&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/dotenv&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/form&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/http-client&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/lock&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/mailer&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/messenger&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/mime&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/property-info&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/serializer&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/stopwatch&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/translation&quot;: &quot;&lt;5.0&quot;,
                  &quot;symfony/twig-bridge&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/twig-bundle&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/validator&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/web-profiler-bundle&quot;: &quot;&lt;4.4&quot;,
                  &quot;symfony/workflow&quot;: &quot;&lt;4.4&quot;
              },
              &quot;require-dev&quot;: {
                  &quot;doctrine/annotations&quot;: &quot;~1.7&quot;,
                  &quot;doctrine/cache&quot;: &quot;~1.0&quot;,
                  &quot;paragonie/sodium_compat&quot;: &quot;^1.8&quot;,
                  &quot;phpdocumentor/reflection-docblock&quot;: &quot;^3.0|^4.0&quot;,
                  &quot;symfony/asset&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/browser-kit&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/console&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/css-selector&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/dom-crawler&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/dotenv&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/expression-language&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/form&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/http-client&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/lock&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/mailer&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/messenger&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/mime&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/polyfill-intl-icu&quot;: &quot;~1.0&quot;,
                  &quot;symfony/process&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/property-info&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/security-csrf&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/security-http&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/serializer&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/stopwatch&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/string&quot;: &quot;~5.0.0&quot;,
                  &quot;symfony/translation&quot;: &quot;^5.0&quot;,
                  &quot;symfony/twig-bundle&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/validator&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/web-link&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/workflow&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;symfony/yaml&quot;: &quot;^4.4|^5.0&quot;,
                  &quot;twig/twig&quot;: &quot;^2.10|^3.0&quot;
              },
              &quot;suggest&quot;: {
                  &quot;ext-apcu&quot;: &quot;For best performance of the system caches&quot;,
                  &quot;symfony/console&quot;: &quot;For using the console commands&quot;,
                  &quot;symfony/form&quot;: &quot;For using forms&quot;,
                  &quot;symfony/property-info&quot;: &quot;For using the property_info service&quot;,
                  &quot;symfony/serializer&quot;: &quot;For using the serializer service&quot;,
                  &quot;symfony/validator&quot;: &quot;For using validation&quot;,
                  &quot;symfony/web-link&quot;: &quot;For using web links, features such as preloading, prefetching or prerendering&quot;,
                  &quot;symfony/yaml&quot;: &quot;For using the debug:config and lint:yaml commands&quot;
              },
              &quot;type&quot;: &quot;symfony-bundle&quot;,
              &quot;extra&quot;: {
                  &quot;branch-alias&quot;: {
                      &quot;dev-master&quot;: &quot;5.0-dev&quot;
                  }
              },
              &quot;autoload&quot;: {
                  &quot;psr-4&quot;: {
                      &quot;Symfony\\Bundle\\FrameworkBundle\\&quot;: &quot;&quot;
                  },
                  &quot;exclude-from-classmap&quot;: [
                      &quot;/Tests/&quot;
                  ]
              },
              &quot;notification-url&quot;: &quot;https://packagist.org/downloads/&quot;,
              &quot;license&quot;: [
                  &quot;MIT&quot;
              ],
              &quot;authors&quot;: [
                  {
                      &quot;name&quot;: &quot;Fabien Potencier&quot;,
                      &quot;email&quot;: &quot;fabien@symfony.com&quot;
                  },
                  {
                      &quot;name&quot;: &quot;Symfony Community&quot;,
                      &quot;homepage&quot;: &quot;https://symfony.com/contributors&quot;
                  }
              ],
              &quot;description&quot;: &quot;Symfony FrameworkBundle&quot;,
              &quot;homepage&quot;: &quot;https://symfony.com&quot;,
              &quot;support&quot;: {
                  &quot;source&quot;: &quot;https://github.com/symfony/framework-bundle/tree/v5.0.11&quot;
              },
              &quot;funding&quot;: [
                  {
                      &quot;url&quot;: &quot;https://symfony.com/sponsor&quot;,
                      &quot;type&quot;: &quot;custom&quot;
                  },
                  {
                      &quot;url&quot;: &quot;https://github.com/fabpot&quot;,
                      &quot;type&quot;: &quot;github&quot;
                  },
                  {
                      &quot;url&quot;: &quot;https://tidelift.com/funding/github/packagist/symfony/symfony&quot;,
                      &quot;type&quot;: &quot;tidelift&quot;
                  }
              ],
              &quot;time&quot;: &quot;2020-07-23T08:36:09+00:00&quot;
          },
      ...
  }
  </code></pre>
  <p><strong><code>symfony.lock</code></strong></p>
  <pre><code>{
      ...
      &quot;symfony/framework-bundle&quot;: {
          &quot;version&quot;: &quot;4.4&quot;,
          &quot;recipe&quot;: {
              &quot;repo&quot;: &quot;github.com/symfony/recipes&quot;,
              &quot;branch&quot;: &quot;master&quot;,
              &quot;version&quot;: &quot;4.4&quot;,
              &quot;ref&quot;: &quot;23ecaccc551fe2f74baf613811ae529eb07762fa&quot;
          },
          &quot;files&quot;: [
              &quot;config/bootstrap.php&quot;,
              &quot;config/packages/cache.yaml&quot;,
              &quot;config/packages/framework.yaml&quot;,
              &quot;config/packages/test/framework.yaml&quot;,
              &quot;config/routes/dev/framework.yaml&quot;,
              &quot;config/services.yaml&quot;,
              &quot;public/index.php&quot;,
              &quot;src/Controller/.gitignore&quot;,
              &quot;src/Kernel.php&quot;
          ]
      },
      ...
  }
  </code></pre>