Working with composer packages
General requisites
When working on the composer packages which you installed into your project
you usually want to fetch their full Git repository. You can tell composer to fetch
the Git repository for certain packages by defining preferred-install
in your
composer configuration at ~/.config/composer/config.json
:
{
"config": {
"preferred-install": {
"john-it-com*": "source"
}
}
}
See Composer documentation for details.
Creating Composer packages
Requisites
The requirements need to be checked only one. Most of the requirements will likely be already configured.
General
- You need to be allowed to create private Github repositories
- You need to be allowed to manage Your Github organization settings
- You need to be allowed to create private packages on Packagist.com
- In Github go to
Your organisation -> Settings -> Github App
and make shure that the appPrivate Packagist
is installed and that the configuration valueRepository access
for this app is set toAll repositories
Add your private packagist to your composer.json
To have your private composer packages available in Composer make shure to add your private packagist to your
composer.json
:
"repositories": [
{
"type": "composer",
"url": "https://repo.packagist.com/big5concepts/",
"canonical": false
}
],
Provide authentication details to Github actions
In your Github organization settings in the
secrets-section
create a secret called COMPOSER_AUTH
(doc) where
you put in a minified version of your composers auth.json.
You can minify the auth.json
file using the following command:
jq -c . < ~/.config/composer/auth.json
In your Github workflow yml make shure to provide the secret as an environment variable. Example:
- name: build
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
run: bin/ptr build
Creating the package
- Create a private Github repository and put all your code inside. Make shure to add a
composer.json
. - Create a new Composer package inside of Your Packagist.com organization and make shure to provide the URL of your Github repository