Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
Composer: How to override a requirement globally for composer.json?

TL;DR:

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.

How to do that?

More in detail:

In a symfony project we require the following library:

"require": {
   "emanueleminotto/twig-cache-bundle": "1.0.2",
}

This library requires itself another library that is currently broken:

"require": {
    "asm89/twig-cache-extension": "^1.3"
},

For the broken library exists already a pull request for over 4 month but the maintainer refuses to merge it.

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?

For the asm89/twig-cache-extension exists the following fork with fixes: https://github.com/blackandred/twig-cache-extension

I tried to add this fork to my composer.json and registered the fork explicitly under "repositories":

"repositories": [
    {
        "type": "git",
        "url": "https://github.com/blackandred/twig-cache-extension"
    }
],

and added the dependency also in my composer-json with a changed version to "dev-master":

"require": {
    "asm89/twig-cache-extension": "dev-master",
    "emanueleminotto/twig-cache-bundle": "1.0.2",
}

But since the emanueleminotto/twig-cache-bundle still requires the original library, composer ignores the fork and installs the original.

Anything i can do here?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I believe the docs have a good example for this scenario.

Basically you need to define an alias in your composer.json as following:

"require": {
    "asm89/twig-cache-extension": "dev-master  as 1.3",
    "emanueleminotto/twig-cache-bundle": "1.0.2",
}

Added by the questioner:

One step was still missing: "composer update asm89/twig-cache-extension"

about 4 years ago · Santiago Trujillo Relatório

0

Add the replace section into composer.json of your fork:

{
    "replace": { 
        "asm89/twig-cache-extension": "self.version" 
    } 
}
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda