How to add non-public repositories from command line with composer?

Solution 1:

You can run the following from the project root to add a repository to the project's composer.json:

composer config repositories.repo-name vcs https://github.com/<orgname or username>/repo

Then you can require the specific repo with:

composer require <orgname or username>/repo:dev-branchname