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

How to use composer to install part of a git repository?(如何使用 composer 安装部分 git 存储库?)
本文介绍了如何使用 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).

这篇关于如何使用 composer 安装部分 git 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)