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
- Go to Variables, Keys & Assets and generate a new SSH key:
Generating SSH key
- Enter
id_rsa
as the name and click Add this variable to add the key:
Adding private key
Once done, you can use the public key to authorize in the repository.
Authorization with OAuth token GitHub
- Generate a personal access token in the GitHub settings. While adding, make sure to select the
repo
scope:
Selecting scope of PSA permissions in GitHub
- In Buddy, go to Variables, Keys & Assets and add a new variable named
GH_TOKEN
. As the value, paste the generated GitHub token:
Saving GitHub token as variable
- Go to your PHP action and enter the following before
composer install
:
composer config github-oauth.github.com ${GH_TOKEN}
composer install
$$
Authorization with GitLab Token
- Generate a personal access token in the GitLab settings. Make sure the expiration date is extended enough:
Creating personal access token in GitLab
- In Buddy, go to Variables, Keys & Assets and add a new variable named
GL_TOKEN
. As the value, paste the generated GitLab token:
Saving GitLab token as variable
- Go to your PHP action and enter the following command before
composer install
:
composer config gitlab-token.gitlab.com ${GL_TOKEN}
composer install
$$
Authorization with HTTP Basic Auth
- Go to Variables, Keys & Assets and add two variables with repository credentials (login/pass):
Saving server credentials as variable
- Go to your PHP action and enter the following command before
composer install
:
composer config --global --auth http-basic.repo.example.org ${AUTH_USER} ${AUTH_PASS}
composer install
$$
Last modified on January 31, 2024