如何使用 composer 安装部分 git 存储库?
我只想需要一个 git 存储库的子部分(而不是完整的东西).我想这样做的原因是因为存储库很大.
I want to require only a sub portion of a git repository (instead of the full thing). The reason i want to do this is because the repository is huge.
在我的情况下,存储库是:https://github.com/pubnub/pubnub-api.git 我只想要/php 目录.
In my case the repository is: https://github.com/pubnub/pubnub-api.git and I only want the /php directory.
我在 composer 中定义了以下包:
I have the following package defined in composer:
{
"type": "package",
"package": {
"name": "pubnub",
"version": "dev-master",
"source" : {
"url": "https://github.com/pubnub/pubnub-api.git",
"type": "git",
"reference":"master"
}
}
},
有什么建议吗?
推荐答案
给出"有没有办法只克隆一个 git 存储库的子目录?" 是 "No" ,并且作曲家将需要子目录签出功能来满足所需的功能,那么我建议作曲家可以做的最好的事情是签出整个内容,然后删除您不想要的内容.
Given the answer to "Is there any way to clone a git repository's sub-directory only?" 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.
简而言之:不可能.
更长的答案:是 git 可以执行 sparse checkout 所以理论上作曲家有朝一日可以支持该功能.您可以使用 autoload 字段仅加载您想要的代码部分(即,不加载整个库).
The longer answer: is that git can do a sparse checkout so in theory composer could someday support that feature. You can use the autoload field to only load the section of code you want (ie, not load the whole lib).
相关文章