Skip to content

Instantly share code, notes, and snippets.

@yidas
Last active April 23, 2024 04:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yidas/4d8c9fad4e9cd011b3854241485961cd to your computer and use it in GitHub Desktop.
Save yidas/4d8c9fad4e9cd011b3854241485961cd to your computer and use it in GitHub Desktop.
Composer install package via VCS such as GitLab (Private package requirement)

Composer install package via VCS such as GitLab

(Private package requirement)

1. Create composer.json:

{
    "repositories": [                                             
        {                                                         
            "type": "vcs",                                        
            "url": "git@gitlab.com:name/lib-name.git"
        }                                                         
    ]
}

After that, the Composer could install packages via Packagist and your VCS.


2. Composer Install

First, check the current user has the ssh-key permission to access VCS git-ssh repositories.

Then run Composer require for VCS git package with --no-interaction:

composer -n require name/lib-name

--no-interaction would skip auth.json for VCS repositories such as GitLab API, and use giving url to access instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment