How to use Bitbucket private repository in your projects

Using Bitbucket private repository in your projects

There are times when you might want to use your personal private library in another project. For example, you may have many private projects that share a common library that can’t be open source. In this situation, you could use Packagist and pay to have a private repository, or you could use Bitbucket with its FREE private repositories.

To include your private Bitbucket repository via Composer, add the following lines into your composer.json:

"repositories":[
     {
         "type": "vcs",
         "url" : "git@bitbucket.org:yourName/yourRepository.git"
     }
 ]

VCS stands for “version control system.” This includes versioning systems like git, svn, fossil, or hg. The composer has a repository type for installing packages from these systems.

If you launch composer-install now, you have to put a Consumer key into your CLICommand Line Interface. This isn’t a problem, but if you have continuous integration or your deploy system launches composer install the command, you must have an automatic system that can insert the consumer key or some magic script to manage it.

So, to avoid this problem you need to open your main repository, from Bitbucket. To do this, create an ssh key and copy the public key.

After that, you need to open your private library from Bitbucket, add an access ssh key, and paste the previously created public key.

You can now launch composer-install for any request that comes up into your CLI and have a perfect automatic deployment.

Free Resources

Attributions:
  1. undefined by undefined
Copyright ©2025 Educative, Inc. All rights reserved