title: Composer: How to override a requirement globally for composer.json?
body: <h1>TL;DR:</h1>
  
  <p>My Project requires library A, A requires B1.
  B1 is broken but there is a fork B2. 
  I want to achieve that composer will install B2 instead of B1 even if A requires B1 and not B2.</p>
  
  <p>How to do that?</p>
  
  <h1>More in detail:</h1>
  
  <p>In a symfony project we require the following library:</p>
  
  <pre><code>"require": {
     "emanueleminotto/twig-cache-bundle": "1.0.2",
  }
  </code></pre>
  
  <p>This library <a href="https://github.com/EmanueleMinotto/TwigCacheBundle/blob/master/composer.json#L18" rel="nofollow noreferrer">requires itself</a> another library that is currently broken:</p>
  
  <pre><code>"require": {
      "asm89/twig-cache-extension": "^1.3"
  },
  </code></pre>
  
  <p>For the broken library exists already a <a href="https://github.com/asm89/twig-cache-extension/pull/46" rel="nofollow noreferrer">pull request</a> for over 4 month but the maintainer refuses to merge it.</p>
  
  <p>My question is, if it would be possible to overwrite the dependencies also for sub-dependencies, that always the patched fork would be used instead of the original one?</p>
  
  <p>For the asm89/twig-cache-extension exists the following fork with fixes: <a href="https://github.com/blackandred/twig-cache-extension" rel="nofollow noreferrer">https://github.com/blackandred/twig-cache-extension</a></p>
  
  <p>I tried to add this fork to my composer.json and registered the fork explicitly under "repositories":</p>
  
  <pre><code>"repositories": [
      {
          "type": "git",
          "url": "https://github.com/blackandred/twig-cache-extension"
      }
  ],
  </code></pre>
  
  <p>and added the dependency also in my composer-json with a changed version to "dev-master":</p>
  
  <pre><code>"require": {
      "asm89/twig-cache-extension": "dev-master",
      "emanueleminotto/twig-cache-bundle": "1.0.2",
  }
  </code></pre>
  
  <p>But since the <em>emanueleminotto/twig-cache-bundle</em> still requires the original library, composer ignores the fork and installs the original.</p>
  
  <p>Anything i can do here?</p>