Search code examples
symfonycomposer-phptwig

How can I update Twig in Symfony 4?


I am trying to update Twig in Symfony 4 like this:

composer require twig/twig

The error message is:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - twig/extensions is locked to version v1.5.4 and an update of this package was not requested.
    - twig/extensions v1.5.4 requires twig/twig ^1.27|^2.0 -> found twig/twig[v1.27.0, ..., v1.44.2, v2.0.0, ..., v2.14.4] but it conflicts with your root composer.json require (^3.3).

Solution

  • It's often easiest to first remove the package that's blocking the update and then install it again after the update. First do:

    composer remove twig/extensions
    

    and then

    composer require twig/twig
    composer require twig/extensions
    

    This should first remove the extensions, update twig and then install the extensions again.