piotrpress/composer-downloads

This composer plugin adds support for environment variables in composer.json packages URLs.

v1.0.0 2023-12-06 14:31 UTC

This package is auto-updated.

Last update: 2024-12-06 16:37:04 UTC


README

This composer plugin adds support for environment variables in composer.json packages URLs.

Example

You can add tokens, license keys, etc. to package URL using ${ENV} placeholders e.g.:

{
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "example/package",
        "version": "1.0",
        "dist": {
          "type": "zip",
          "url": "https://${VENDOR}.com/${NAME}-${VERSION}.zip?token=${TOKEN}"
        }
      }
    }
  ],
  "require": {
    "php": ">=7.4",
    "example/package": "1.0",
    "piotrpress/composer-downloads": "*"
  },
  "config": {
    "allow-plugins": {
      "piotrpress/composer-downloads": true
    }
  }
}

You can pass environment variables to composer install/update command e.g.:

$ TOKEN=secret composer install

Note: Variables ${VENDOR}, ${NAME}, ${VERSION} are propagated from package's fields.

Processed URL will be:

https://example.com/package-1.0.zip?token=secret

Requirements

  • PHP >= 7.4 version.
  • Composer ^2.0 version.

License

MIT