Symfony installed with symfony new myproject --full --version=4.4
Then trying to run composer require sonata-project/admin-bundle and get following errors:
$ composer require sonata-project/admin-bundle
Using version ^3.62 for sonata-project/admin-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.4.*"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install sonata-project/core-bundle 3.18.0|remove twig/twig v3.0.3|install twig/twig v2.0.0|install twig/twig v2.1.0|install twig/twig v2.2.0|install twig/twig v2.3.0|install twig/twig v2.3.1|install twig/twig v2.3.2
- Conclusion: don't install sonata-project/core-bundle 3.18.0|don't install twig/twig v3.0.3|install twig/twig v2.0.0|install twig/twig v2.1.0|install twig/twig v2.2.0|install twig/twig v2.3.0|install twig/twig v2.3.1|install twig/twig v2.3.2
- Installation request for doctrine/doctrine-bundle (locked at 2.0.7) -> satisfiable by doctrine/doctrine-bundle[2.0.7].
- Conclusion: don't install sonata-project/core-bundle 3.18.0|remove twig/twig v3.0.3|install twig/twig v2.0.0|install twig/twig v2.1.0|install twig/twig v2.2.0|install twig/twig v2.3.0|install twig/twig v2.3.1|install twig/twig v2.3.2
- Conclusion: don't install sonata-project/core-bundle 3.18.0|don't install twig/twig v3.0.3|install twig/twig v2.0.0|install twig/twig v2.1.0|install twig/twig v2.2.0|install twig/twig v2.3.0|install twig/twig v2.3.1|install twig/twig v2.3.2
- Installation request for twig/twig (locked at v3.0.3) -> satisfiable by twig/twig[v3.0.3].
- sonata-project/admin-bundle 3.62.0 requires sonata-project/core-bundle ^3.18.0 -> satisfiable by sonata-project/core-bundle[3.18.0].
- sonata-project/admin-bundle 3.62.1 requires sonata-project/core-bundle ^3.18.0 -> satisfiable by sonata-project/core-bundle[3.18.0].
- Conclusion: don't install sonata-project/core-bundle 3.18.0
- Installation request for sonata-project/admin-bundle ^3.62 -> satisfiable by sonata-project/admin-bundle[3.62.0, 3.62.1].
Installation failed, reverting ./composer.json to its original content.
The message is pretty clear. Dont use twig 3. Use Twig 2.
This is not Symfony 4.4 related
Will try, thanks.
OK, so maybe for someone it would be helpfull, cause this moment don't mentioned anywhere:
Add "twig/twig": "^2.0" line to composer.json require section and run composer update to fallback twig 2 version.
After that composer require sonata-project/admin-bundle runs without errors.
@multifinger This is how works composer. It looks at our composer.json to download what we required.
This line https://github.com/sonata-project/SonataAdminBundle/blob/3.x/composer.json#L58 say that we want a version >= 2.12 and < 3.
And it will be the same for every others packages. Nobody add documentation to say "Be carefull, we need the library that we needs, with the version that we explicitely have declared."
If you interested to using twig 3 (and maybe Symfony 5) you should look at https://github.com/sonata-project/SonataAdminBundle/issues/5788
First time faced the situation with dependency wich needs to be downgraded to fits all requirements. I was wrong in my thougnts that composer is smart enought to handle such situation without errors.
Nevertheless, even if some programmers are smart enought as you to handle all requirements in theirs mind, it still would be nice to mention how to handle with errors during install for such dummies like me.
What I mean is, it's not Sonata who has to document how to handle such error. If you ask that, you ask to EVERY LIBRARY document the same thing. You can face this issue with any library, so I you looking for documentation, it's in the composer documentation/stack overflow.
And if you take slowly the error message from composer, it says
Conclusion:
Most helpful comment
OK, so maybe for someone it would be helpfull, cause this moment don't mentioned anywhere:
Add
"twig/twig": "^2.0"line to composer.json require section and runcomposer updateto fallback twig 2 version.After that
composer require sonata-project/admin-bundleruns without errors.