Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 253
Mike Graf Avatar asked Jan 23 '13 17:01

Mike Graf


2 Answers

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

like image 147
Mike Graf Avatar answered Sep 21 '22 19:09

Mike Graf


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

like image 40
Flavien Avatar answered Sep 19 '22 19:09

Flavien