简体   繁体   English

如何在所需软件包中使用Composer存储库?

[英]How to use Composer repositories in required package?

I have two code repositories. 我有两个代码存储库。 They both have composer.json files (see below). 它们都具有composer.json文件(请参见下文)。 The first composer.json file is required by the second composer.json file, with the former stored remotely on bitbucket. 第一composer.json文件required由第二composer.json文件,前者上到位桶远程地存储。

I have run both composer.json files locally: the first file passes and downloads the vendors as I would expect; 我已经在本地运行了两个composer.json文件:第一个文件通过并下载了我期望的供应商; the second file, which calls the first file, does not and I get this error: 第二个文件,调用第一个文件,没有,我得到这个错误:

Problem 1
- The requested package timeago/timeago could not be found in any version, there may be a typo in the package name.
Problem 2
- The requested package prettify/prettify could not be found in any version, there may be a typo in the package name.

Now, if I remove all repositories from the first file, and their corresponding entries in requires , then all works as expected and the files are downloaded. 现在,如果我请从第一个文件的所有信息库,以及它们相应的条目requires ,那么所有的作品如预期,并且文件被下载。 So, I think the problem lies with the repositories section in the first file somehow. 因此,我认为问题在于第一个文件中的repositories部分。 Any ideas? 有任何想法吗?

Here are my two composer files: 这是我的两个作曲家文件:

File one: 文件一:

"repositories": {
    "prettify/prettify": {
        "type": "package",
        "package": {
            "name": "prettify",
            "version": "dev-master",
            "source": {
                "url": "http://google-code-prettify.googlecode.com",
                "type": "svn",
                    "reference": "svn/trunk"
            }
        }
    },
    "timeago/timeago": {
        "type": "package",
        "package": {
            "name": "timeago",
            "version": "dev-master",
            "source": {
                "url": "https://github.com/rmm5t/jquery-timeago.git",
                "type": "git",
                    "reference": "master"
            }
        }
    },
    "require": {
        "timeago": "dev-master",
        "prettify": "dev-master",
    }
}

File two: 文件二:

"require": {
    "vendor/project": "master"
},

If you use private repositories mentioned in the composer.json of a dependency of your main package, you have to repeat them there. 如果您使用主软件包的依赖项的composer.json中提到的私有存储库,则必须在其中重复它们。

Alternatively you can set up an instance of Satis to create the necessary metadata from all the private repositories you use, and simply link this instead. 另外,您可以设置一个Satis实例来从您使用的所有私有存储库中创建必要的元数据,而只需链接它即可。

Composer will NOT recursively scan repositories for further links to other repositories, because that would lead to infinite scan times and really poor performance, and ultimately to undecidable problems as well, so whatever package you are using has to either only use Packagist as a source, or must mention the source for all packages that should override or add to Packagist. Composer不会递归地扫描存储库以查找与其他存储库的进一步链接,因为这将导致无限的扫描时间和确实很差的性能,并最终也导致无法确定的问题,因此,无论您使用什么软件包,都必须仅使用Packagist作为源,或必须提及所有应覆盖或添加到Packagist的软件包的来源。

Having one single Satis instance that acts as a complete map of all your private repositories will really ease the process. 拥有一个Satis实例作为您所有私有存储库的完整映射,确实可以简化此过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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