简体   繁体   中英

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). 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.

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"
                }
            }
    },

Any tips?

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.

In short: Not Possible.

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).

It seems that the php directory has been moved on its own repository here https://github.com/pubnub/php . That may help for this project, but no idea how to achieve this from main repo and composer...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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