Composer PHP packages

View as Markdown

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.

Info
You can also publish packages to the Composer registry in your Buddy workspace and install them without SSH keys or Git tokens. See Private Composer packages in Buddy.

Authorization with SSH key

  1. Go to Variables, Keys & Assets and generate a new SSH key:

Image loading...Generating SSH key

  1. Enter id_rsa as the name and click Add this variable to add the key:

Image loading...Adding private key

Once done, you can use the public key to authorize in the repository.

Authorization with OAuth token GitHub

  1. Generate a personal access token in the GitHub settings. While adding, make sure to select the repo scope:

Image loading...Selecting scope of PSA permissions in GitHub

  1. In Buddy, go to Variables, Keys & Assets and add a new variable named GH_TOKEN. As the value, paste the generated GitHub token:

Image loading...Saving GitHub token as variable

  1. Go to your PHP action and enter the following before composer install:
bash
 composer config github-oauth.github.com ${GH_TOKEN}
 composer install
$$

Authorization with GitLab Token

  1. Generate a personal access token in the GitLab settings. Make sure the expiration date is extended enough:

Image loading...Creating personal access token in GitLab

  1. In Buddy, go to Variables, Keys & Assets and add a new variable named GL_TOKEN. As the value, paste the generated GitLab token:

Image loading...Saving GitLab token as variable

  1. Go to your PHP action and enter the following command before composer install:
bash
composer config gitlab-token.gitlab.com ${GL_TOKEN}
composer install
$$

Authorization with HTTP Basic Auth

  1. Go to Variables, Keys & Assets and add two variables with repository credentials (login/pass):

Image loading...Saving server credentials as variable

  1. Go to your PHP action and enter the following command before composer install:
bash
composer config --global --auth http-basic.repo.example.org ${AUTH_USER} ${AUTH_PASS}
composer install
$$

Last modified on Nov 16, 2026