简体   繁体   English

如何使用composer安装git存储库的一部分?

[英]How to use composer to install part of a git repository?

I want to require only a sub portion of a git repository (instead of the full thing). 我想只需要一个git存储库的子部分(而不是完整的东西)。 The reason i want to do this is because the repository is huge. 我想这样做的原因是因为存储库很大。

In my case the repository is: https://github.com/pubnub/pubnub-api.git and I only want the /php directory. 在我的情况下,存储库是: https//github.com/pubnub/pubnub-api.git ,我只想要/ php目录。

I have the following package defined in composer: 我在composer中定义了以下包:

   {
            "type": "package",
            "package": {
                "name": "pubnub",
                "version": "dev-master",
                "source" : {
                    "url": "https://github.com/pubnub/pubnub-api.git",
                    "type": "git",
                    "reference":"master"
                }
            }
    },

Any tips? 有小费吗?

Given the answer to "Is there any way to clone a git repository's sub-directory only?" 给出答案“有没有办法克隆git存储库的子目录?” Is "No" , and sub directory checkout functionality would be required by composer to satisfy the desired functionality, then I would suggest the best composer could do was checkout the whole thing and then delete what you didnt want. “否” ,并且作曲家需要子目录结帐功能来满足所需的功能,然后我建议最好的作曲家可以做的就是检查整个事情,然后删除你不想要的东西。

In short: Not Possible. 简而言之:不可能。

The longer answer: is that git can do a sparse checkout so in theory composer could someday support that feature. 更长的答案是:git可以做一个稀疏的结账,所以理论上作曲家有一天可以支持这个功能。 You can use the autoload field to only load the section of code you want (ie, not load the whole lib). 您可以使用自动加载字段仅加载所需的代码段(即,不加载整个库)。

It seems that the php directory has been moved on its own repository here https://github.com/pubnub/php . 似乎php目录已在其自己的存储库中移动https://github.com/pubnub/php That may help for this project, but no idea how to achieve this from main repo and composer... 这可能有助于这个项目,但不知道如何从主回购和作曲家实现这一目标......

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

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