Zum Inhalt

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

  1. You need to be allowed to create private Github repositories
  2. You need to be allowed to manage Your Github organization settings
  3. You need to be allowed to create private packages on Packagist.com
  4. In Github go to Your organisation -> Settings -> Github App and make shure that the app Private Packagist is installed and that the configuration value Repository access for this app is set to All 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

  1. Create a private Github repository and put all your code inside. Make shure to add a composer.json.
  2. Create a new Composer package inside of Your Packagist.com organization and make shure to provide the URL of your Github repository