Composer features

The conflict key in a Composer composer.json

The conflict key in a Composer composer.json file is used to declare packages that your project cannot work with. It’s a way to prevent the installation of certain versions of packages that you know would cause problems with your project.

Example:

"conflict": {
    "cocur/slugify": "4.5.0"
}

This configuration means that your project cannot be installed or updated if the version 4.5.0 of the cocur/slugify package is also required. If another dependency in your project requires cocur/slugify version 4.5.0, or if you try to require that version directly, Composer will throw a conflict error and prevent the installation or update.

The conflict key is useful when you know that a particular version of a package has a bug or a breaking change that affects your project, and you want to ensure that Composer does not install that version.

In summary, this configuration tells Composer: “My project cannot work with version 4.5.0 of the cocur/slugify package, so please do not install that version.”


Андрей Писаревский

Author: Andrei Pisarevskii 

PHP | WordPress Team Lead. I have commercial programming experience since 2010 and expertise in the full cycle of web development: Frontend, Backend, QA, Server administration, managing large teams and Enterprise projects.

Leave a Reply

Your email address will not be published. Required fields are marked *