Install composer package from private gitlab

Published 6 months ago by EmilMoe

I have been struggling a bit getting it to work to delegate some of my features to a private gitlab repo. I am not sure how I should configure it in my composer.json.

Seems like I'm messing something up with a token or ssh key. As far as I can tell it would be easiest with at token, when I am going to distribute the code to several servers?

bobbybouwmann

Well best practice for Gitlab is using a deploy ssh key for this kind of stuff.

Documentation: https://docs.gitlab.com/ee/ssh/#deploy-keys

EmilMoe

Thanks. I know about ssh keys and deploy keys, but what I don't know about is the configuration in composer

bobbybouwmann

Aah oke I get you now! Well you can use the basic-auth functionality from composer: https://getcomposer.org/doc/articles/http-basic-authentication.md

There is also a command-line version of this call

composer config --auth http-basic.www.gitlab.com $USERNAME $PASSWORD --no-ansi --no-interaction

It basically adds everything to an auth.json file in the ~/.composer directory. You only need to add this once on your server ;) If you use something like docker, it's recommended to use the command line version.

Please sign in or create an account to participate in this conversation.