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. 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 Feb 12, 2024