0

Using composer, I want to install repository from our private gitlab (internal gitlab not available online). I tried different approach, but did not seems to get what I want.

In composer.json, here is how I added a repository from our personnal gitlab.

"repositories": {
   "domain-wordpress/plugin-flux-mention": {
       "type": "git",
       "url": "http://git.domain.com/wordpress/plugin-flux-mention.git"
    }
}

I tried using type vcs, or type gitlab but I add some authentification problem, so does anyone know how to set authentification for every single type (git, gitlab or vcs)?

Using the type git I managed to pass authentification problem. For type git I had to add the following in composer.json

"config": {
    "gitlab-domains": ["git.domain.com"],
    "gitlab-token": {"git.domain.com":  "Mytoken"}
},

With those two configuration, everything work, but the master branched is used when I do not specify a tag. How can I tell composer to only install tag ?

Cache:

Using type git is there any cache ?

Using vcs, I seemed to have some kind of cache but I'm not sure.

1 Answer 1

0

Authentication

If you have a regular composer package in your gitlab repository it will work with vcs as repository type. To tackle your authentication issues, create a SSH key pair on your local machine and add the public key to your gitlab account.

Create the key:

ssh-keygen -o -t rsa -b 4096 -C "[email protected]"

Copy public key to your clipboard (depending on your OS)

pbcopy < ~/.ssh/id_ed25519.pub (OSX)

xclip -sel clip < ~/.ssh/id_ed25519.pub (Linux)

cat ~/.ssh/id_ed25519.pub | clip (Windows)

Then log into your Gitlab account and:

Add your public SSH key to your GitLab account by clicking your avatar in the upper right corner and selecting Settings. From there on, navigate to SSH Keys and paste your public key in the “Key” section. If you created the key with a comment, this will appear under “Title”. If not, give your key an identifiable title like Work Laptop or Home Workstation, and click Add key.

To test if it works:

ssh -T [email protected]

This is taken from the GitLab docs

Install a specific branch or tag

In your composer.json locate the require section and add your package like:

{
    "require" : {
        "domain-wordpress/plugin-flux-mention": "1.0.0"
    }
} 

If you like to install a specific branch use "dev-$branchname" so for the branch with the name develop the branch name would be dev-develop.

Cache

Composer caches vcs by default. To figure out if your repository is cached, locate your global Composer installation (on OSX it is ~/.composer). The caches are inside the cache/vcs folder:

$ ls ~/.composer/cache/vcs

For more information about Composer cache consult the documentation

1
  • Ok so I managed to do everything, except for cache. Do you know if there is some kind of cache, or if there is a git clone every single time?
    – LinChan
    Dec 18, 2018 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.