Čamo
Čamo

Reputation: 4170

How to force version of dependence library in Composer

I have a composer.json which contains library nette/nette which has dependence to other library nette/deprecated and this nested library has a bug in newer version. So I need to force Composer to load previous version of nested library nette/deprecated. The problem is that the main library nette/nette need s to be of version "nette/nette": "~2.4.0" but all the 2.4 and also 2.5 versions depends on the buggy nette/deprecated library. How to force Composer to load exactly required version of nested nette/deprecated library? It seems it is not possible or I am not enough educated in Composer features. Thanks.

Upvotes: 1

Views: 881

Answers (1)

dbrumann
dbrumann

Reputation: 17166

If you know that a dependency has a bug or interferes with something in your code you can mark it as conflicting in your composer.json.

{
    "...",
    "require": {
        "..."
    },
    "conflict": {
        "nette/deprecated": ">2.4.0,<3.0.0"
    }
}

This will exclude everything after 2.4.0 and smaller than 3.0.0, but you can change the value to whatever you need it to be. This way you can communicate clearly, that there are certain versions that are off limits without explicitly declaring this as a root dependency.

See also: https://getcomposer.org/doc/04-schema.md#conflict

Upvotes: 5

Related Questions