Composer PHP packages

When you create a project, you often use a pre-set library already written in PHP. Private dependencies can help you download these external packages/libraries. This article will tell you how to serve private projects in the Composer dependencies in Buddy.

Authorization with SSH key

  1. Generate a new pair of SSH keys in the terminal (make sure they’re not secured by a passphrase): bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  2. Add the private key to Environment variables in Buddy and enter id_rsa as the name.

  3. Authorize the public key in the repository.

Authorization with HTTP Basic Auth

  1. Add the environment variables with login and password to the repository:
  2. Enter the following command before composer install:

    composer config --global --auth http-basic.github.com ${AUTH_USER} ${AUTH_PASS}
    composer install
    $$
If the host is different from GitHub, just change the first element to http-basic.gitlab.com / http-basic.bitbucket.org, etc.

Authorization with OAuth token GitHub

  1. Generate a token in GitHub settings. While adding, select the scope repo: Selecting scope of permissions in GitHubSelecting scope of permissions in GitHub
  2. Add an enviroment variable named GH_TOKEN and paste the value from the previous step:
  3. Enter the following command before composer install:
 composer config github-oauth.github.com ${GH_TOKEN}
 composer install
$$

Authorization with GitLab Token

  1. Generate a token in GitLab settings. Make sure the expiration date is extended enough: Selecting scope of permissions in GitLabSelecting scope of permissions in GitLab
  2. Add an environment variable named GL_TOKEN and paste the value from the previous step:
  3. Enter the following command before composer install:

    composer config gitlab-token.gitlab.com ${GL_TOKEN}
    composer install
    $$

Last modified on May 9, 2022

Get Started

Sign up for free and deploy your project in less than 10 minutes.