Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install a package from a repository on Gitlab using Composer?

I am trying to get composer to download a library from my repository on Gitlab, however, it does not have a composer.json file in it so I'm not sure if this is possible.

    "require": {
        "username/repository-name"
    },
    "repositories": [{
        "type": "package",
        "package": {
            "version": "dev-master",
            "name": "username/repository-name",
            "source": {
                "url": "https://gitlab.com/username/repository.git",
                "type": "git",
                "reference": "master"
            }
        }
    }],
like image 735
Thanh Nguyen Avatar asked Jan 14 '16 03:01

Thanh Nguyen


People also ask

Where does composer get packages from?

Composer downloads directly from the source, e.g. Packagist only knows those source and tells your composer instance where to go. It does this by downloading a bunch of json files from Packagist.org that have all the infos.


1 Answers

I found the answer and it works for me here (the last answer, not the accepted answer):

Using Composer and Private Repository on GIthub using VCS on Build Server

This is what I make it works:

    "repositories": [
      {
        "type": "package",
        "package": {
          "name": "username/repository",
          "version": "0.1.0",
          "type": "package",
          "source": {
              "url": "[email protected]:username/repository.git",
              "type": "git",
              "reference": "master"
          }
        }
      }
    ],
    "require": {           
        "username/repository": "*"
    },
like image 71
Thanh Nguyen Avatar answered Oct 07 '22 16:10

Thanh Nguyen