George Irimiciuc
George Irimiciuc

Reputation: 4633

Install composer package by ignoring one of its dependencies

I have a Symfony2 project and want to add the AdminGenerator to it.

So I

composer require cedriclombardot/admingenerator-generator-bundle

And get the following error

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

  Problem 1
    - cedriclombardot/admingenerator-generator-bundle v1.1.3 requires twig/extensions 1.0.* -> no matching package found.
    - cedriclombardot/admingenerator-generator-bundle v1.1.2 requires twig/extensions 1.0.* -> no matching package found.
    - cedriclombardot/admingenerator-generator-bundle v1.1.1 requires twig/extensions 1.0.* -> no matching package found.
    - cedriclombardot/admingenerator-generator-bundle v1.1.0 requires twig/extensions 1.0.* -> no matching package found.
    - Installation request for cedriclombardot/admingenerator-generator-bundle ^1.1 -> satisfiable by cedriclombardot/admingenerator-generator-bundle[v1.1.0, v1.1.1, v1.1.2, v1.1.3].

This is obvious, I have twig/extensions 1.3 and the package wants me to have 1.0.*. If I downgrade twig/extensions to 1.0.* it works perfectly, but I don't want to do that because it has a lot of deprecated things, and they will be removed soon in the 2.0 version of it.

How can I install the admin generator package while keeping my twig/extensions package at version 1.3 ?

My composer.json require, if it helps:

 "require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.7.*",
    "doctrine/orm": "~2.2,>=2.2.3,<2.5",
    "doctrine/dbal": "<2.5",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "doctrine/doctrine-migrations-bundle": "^1.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "cunningsoft/chat-bundle": "^0.4.0",
    "knplabs/knp-time-bundle": "^1.3",
    "helthe/turbolinks-bundle": "~1.1",
    "knplabs/knp-paginator-bundle": "^2.4",
    "knplabs/knp-menu-bundle": "~2",
    "twig/extensions": "^1.3"
  },

I want to do this not only to have the latest version, but also because later on I will do composer update, so I don't want to have problems, then, too.

Upvotes: 0

Views: 964

Answers (1)

tchap
tchap

Reputation: 3432

Fiddling with dependencies on a vendor package is not recommended and even if you did find a way to change it (in the composer.json file of the vendor package, for instance), you would lose all the benefits of using composer since the next update would gladly override / break your changes and your whole project.

But what seems possible is you could use the latest branch of the package, that doesn't require Twig Extensions at all :

https://packagist.org/packages/cedriclombardot/admingenerator-generator-bundle#dev-master

composer require cedriclombardot/admingenerator-generator-bundle:dev-master

Upvotes: 1

Related Questions