我如何在没有依赖的情况下在composer中安装软件包 [英] how can I install package in composer without dependency

查看:80
本文介绍了我如何在没有依赖的情况下在composer中安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 composer symfony php

有一个捆绑包A 依赖于另一个捆绑包B v 1.1

但是我拥有最新版本的 Bundle B v 2

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

现在我想要安装 Bundle A 而不安装其依赖项 bundle B v 1.1

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

我该如何进行?请提出建议。

How do I proceed ? Please suggest.

推荐答案

设置:

最新的瓢虫捆绑版本是 1.0.2 ,但同时还有更多提交。它要求瓢虫版本为 1.0.8 ,其中也不包括最新更改。

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.

解决方案:

一个简单的解决方案是使用 inline-alias 。像这样的东西:

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"
}

替代:

您可以在 composer.json

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

只需复制原始软件包中的软件包定义,添加dist / source位置并编辑需求。

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

composer随后将使用此新程序包定义,因为它会从所有已知存储库中选择第一个匹配项(总是查询packagist)。

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

您应该为dist-zip选择一个特定的提交。示例:

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"
            },
        }
    }
],

现在需要中的 raulfraile / ladybug-bundle:〜1.0 composer.json ,它将使用您自己定义的 1.0.3 版本。

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

这篇关于我如何在没有依赖的情况下在composer中安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆