Most of the PHP framework now a day uses private packages from repositories using a Composer. To install a private package with the composer, we need to set the additional configuration for our composer.json file. Then we need to generate an SSH key and register it to our existing Git Repository. Just follow the steps below.
1. Configure Composer
Add a repository to your composer.json and point it to the Git Repository where your package is stored.
"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:username/codebook.git"
}
]
2. Create an SSH key
Create an SSH Key on the machine on which you want to install the package.
- Open Command Prompt and execute this command.
Note that the ssh-keygen
command is only available if you have already installed Git
ssh-keygen -t rsa -C "samplemail@example.com"
- You’ll get a response similar to this.
- Just press enter to use the default location. Next you will be ask to enter passphrase.
- To locate the SSh key you can use location below.
%userprofile%/.ssh
- If you are on a development machine, you probably want to add the SSH key to your GitHub or Bitbucket account. This gives you access to all private repositories on your account.
For your reference you can visit the link below:
3. Run composer
Lastly, you can run composer require or composer install to install the package.
That’s it! You now have the steps on how you can install a private package with the composer. Happy Coding!!
For more related to Software development topic you can visit my Home Page. Link