Thanh Nguyen
Thanh Nguyen

Reputation: 5342

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

Upvotes: 22

Views: 23763

Answers (1)

Thanh Nguyen
Thanh Nguyen

Reputation: 5342

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

Upvotes: 36

Related Questions