简体   繁体   中英

how can I install package in composer without dependency

I am using composer with symfony php .

There is one bundle A which has dependency on Another bundle B v 1.1 .

But I have the latest version of bundle B v 2 .

Now I want to install bundle A without installing its dependency bundle B v 1.1 .

How do I proceed ? Please suggest.

setup:

The latest ladybug-bundle version is 1.0.2 but there have meanwhile been some more commits. It requires ladybug version is 1.0.8 which doesn't include the latest changes aswell.

solution:

An easy solution would be using an inline-alias . Something like:

"require" : {
    "raulfraile/ladybug-bundle": "dev-master as 1.0.3"
    "raulfraile/ladybug": "dev-master as 1.0.9"
}

alternative:

You can define a package with the same name in your composer.json that includes the altered dependency.

Just copy the package definition from the original package, add the dist/source locations and edit the requirements.

composer will then use this new package definition because it picks the first match from all known repositories (packagist is always queried last).

You should choose a specific commit for the dist-zip. An example:

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "raulfraile/ladybug-bundle",
            "version": "1.0.3",
            "require": {
               "raulfraile/ladybug" : "~1.0@dev"
            },
            "dist": {
                "url": "https://github.com/raulfraile/LadybugBundle/archive/5c3739a881313f63f7b47ace49af5deeed211362.zip",
                "type": "zip"
            },
        }
    }
],

Now require "raulfraile/ladybug-bundle": "~1.0" in your composer.json and it will use the 1.0.3 version you defined yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM