加载两个自定义库 [英] Load two custom libraries

查看:145
本文介绍了加载两个自定义库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Composer从另一个自定义库中加载自定义库时遇到了一些问题

I have some problem by using Composer to load a custom library from another custom library

我有2个自定义库称为 ia / audit_trail和 ia / flash。并且 ia / audit_trail需要 ia / flash才能工作。

I have 2 custom libraries called "ia/audit_trail" and "ia/flash". And "ia/audit_trail" needs "ia/flash" to work.


audit_trail: https://github.com/pierrererot/audit_trail

flash: https://github.com/pierrererot/flash

因此,我设置了require属性来调用另一个属性。没什么特别的,但是,当我在主项目中运行简单的 composer update -vvv 时,出现此错误:

So, I have the require property set for calling another one. Nothing special, BUT, when I run a simple composer update -vvv in my main project, I got this error :

您的要求无法解决为一组可安装的软件包。

问题1

-ia / audit_trail_component的安装请求〜1.0.0- >可由ia / audit_trail_component [1.0.0]满足。

-ia / audit_trail_component 1.0.0要求ia / flash_component〜1.0.0->找不到匹配的软件包。

Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for ia/audit_trail_component ~1.0.0 -> satisfiable by ia/audit_trail_component[1.0.0].
- ia/audit_trail_component 1.0.0 requires ia/flash_component ~1.0.0 -> no matching package found.

可能的原因:

-软件包名称中有错字

-该软件包无法稳定使用版本根据您的最小稳定性设置

参见 https: //getcomposer.org/doc/04-schema.md#minimum-stability 了解更多详细信息。

-这是一个私有软件包,您忘了添加自定义存储库来找到它

Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://getcomposer.org/doc/04-schema.md#minimum-stability for more details.
- It's a private package and you forgot to add a custom repository to find it

阅读 https://getcomposer.org/ doc / articles / troubleshooting.md 进一步的常见问题...

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems...

但是,如果我直接将这两个库放到一起进入我的主要项目(因此,如果一个库不需要另一个库),它就可以工作!

BUT, if I put these two librairies directly into my main project (so if one librairy doesn't need another librairy), it works !.

这是我主要项目的 composer.json

{
    "require": {
        "ia/audit_trail_component": "1.0.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/pierrererot/audit_trail.git"
        }
    ]
}

好的。因此,我确实需要自定义的 audit_trail库。现在,这是我的自定义 audit_trail库的 composer.json

All right. So I did require my custom "audit_trail" library. So now, here is the composer.json of my custom "audit_trail" library :

{
    "name": "ia/audit_trail_component",
    "version": "1.0.0",
    "type": "library",
    "require": {
        "ia/flash_component": "1.0.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/pierrererot/flash.git"
        }
    ],
    "minimum-stability": "dev"
}

好的。因此,我确实需要自定义的 Flash库。然后,这是我的自定义 flash库的 composer.json

All right. So I did require my custom "flash" library. And then, here is the composer.json of my custom "flash" library :

{
    "name": "ia/flash_component",
    "version": "1.0.0",
    "description": "Flash Component",
    "type": "library",
    "minimum-stability": "dev"
}

如您所见,在我的作曲家文件中一切似乎都正常,所以我不明白自己错过了什么。

As you can see, everything seems ok in my composer files, so I don't understand what I missed.

在您问之前,我先弄清楚了这些事情:

Before you ask, I precise these things :


  • 两个库都在其Git存储库上推送了一个 dev和一个 master分支

  • Both libraries have a "dev" and a "master" branch pushed on their Git repositories

两个库在其Git存储库上至少推送了1.0.0标签

Both libraries have a minimum 1.0.0 tag pushed on their Git repositories

推荐答案

存储库设置仅用于root用户-Composer将忽略所有依赖项的此设置,仅使用在主项目中定义的这些存储库。

repositories setting is root-only - Composer will ignore this setting for all dependencies and use only these repositories defined in your main project.


存储库仅可用于根软件包,并且不会加载依赖项中定义的存储库。阅读常见问题解答条目想了解原因。

https://getcomposer.org/doc/05-repositories.md#repository

因此,您需要将所有必要的存储库添加到主项目的 composer.json 中:

So you need add all necessary repositories into composer.json of your main project:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/pierrererot/audit_trail.git"
    },
    {
        "type": "vcs",
        "url": "https://github.com/pierrererot/flash.git"
    }
],

这篇关于加载两个自定义库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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