PHPackages                             codewithkyrian/platform-package-installer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. codewithkyrian/platform-package-installer

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

codewithkyrian/platform-package-installer
=========================================

A Composer plugin for platform-aware distribution URL resolution

2.1.0(2mo ago)8212.1k↓59.3%2[1 issues](https://github.com/CodeWithKyrian/platform-package-installer/issues)7MITPHPPHP ^8.1CI passing

Since Dec 14Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/CodeWithKyrian/platform-package-installer)[ Packagist](https://packagist.org/packages/codewithkyrian/platform-package-installer)[ RSS](/packages/codewithkyrian-platform-package-installer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (11)Versions (10)Used By (7)

Composer Platform Package Installer
===================================

[](#composer-platform-package-installer)

The Composer Platform Package Installer is a powerful plugin for platform-aware distribution URL resolution.

The core behavior is simple:

- Your package declares platform-specific artifact URLs or URL templates in `composer.json`
- At install time, the plugin picks the best URL for the current OS/architecture
- It resolves placeholders (built-in `{version}` plus optional custom variables)
- It tells Composer to download and install the package from that resolved URL

Requirements
------------

[](#requirements)

- PHP 8.1+
- Composer 2+

Installation
------------

[](#installation)

Install the plugin using Composer:

```
composer require codewithkyrian/platform-package-installer
```

Then change your package type to `platform-package` in `composer.json`:

```
{
  "name": "org/your-platform-package",
  "type": "platform-package",
  "require": {
    "codewithkyrian/platform-package-installer": "^2.0"
  }
}
```

Core Configuration
------------------

[](#core-configuration)

All core behavior is configured in `composer.json` under `extra.artifacts`.

Legacy `extra.platform-urls` is still supported for backward compatibility, but is deprecated.

### Format A: Simple (no custom variables)

[](#format-a-simple-no-custom-variables)

Use this when:

- you are using direct artifact URLs with no placeholders, or
- `{version}` is the only placeholder you need.

```
{
  "extra": {
    "artifacts": {
      "darwin-arm64": "https://cdn.example.com/pkg/{version}/darwin-arm64.zip",
      "linux-x86_64": "https://cdn.example.com/pkg/{version}/linux-x86_64.tar.gz",
      "all": "https://cdn.example.com/pkg/{version}/universal.zip"
    }
  }
}
```

### Format B: Extended (custom variables + defaults)

[](#format-b-extended-custom-variables--defaults)

Use this when templates include additional placeholders beyond `{version}`.

```
{
  "extra": {
    "artifacts": {
      "urls": {
        "darwin-arm64": "https://cdn.example.com/pkg/{version}/variant-{runtime}/darwin-arm64.zip",
        "linux-x86_64": "https://cdn.example.com/pkg/{version}/variant-{runtime}/linux-x86_64.tar.gz"
      },
      "vars": {
        "runtime": "gpu"
      }
    }
  }
}
```

Application-Level Variable Overrides
------------------------------------

[](#application-level-variable-overrides)

Consumers of your platform package can override variables from their root project:

```
{
  "extra": {
    "platform-packages": {
      "org/your-platform-package": {
        "runtime": "cpu"
      }
    }
  }
}
```

Variable precedence:

1. Root app override (`extra.platform-packages.`)
2. Package default (`extra.artifacts.vars`)
3. Built-in `{version}` (always provided by plugin)

Placeholder Behavior
--------------------

[](#placeholder-behavior)

- `{version}` is built in and always available
- Any `{name}` placeholder can be used
- Unresolved placeholders cause artifact URL resolution to fail for that package
- If override variables resolve to a URL that does not exist, the plugin retries with package default variables
- On failure, Composer falls back to the package's original `dist` configuration

Platform Matching
-----------------

[](#platform-matching)

The plugin matches the current machine against keys in `artifacts`:

- OS-only keys: `linux`, `darwin`, `windows`, `raspberrypi`
- OS + architecture keys: `darwin-arm64`, `linux-x86_64`, `windows-32`, `windows-64`, etc.
- `all` as final fallback

More specific matches are preferred over generic ones.

Optional Helper: Generate URLs Command
--------------------------------------

[](#optional-helper-generate-urls-command)

`platform:generate-urls` is a helper to generate artifact URL entries from a template.

```
composer platform:generate-urls --dist-type=github --repo-path=vendor/repo --platforms=linux-x86_64 --platforms=darwin-arm64
```

You can also provide platforms as a comma-separated list:

```
composer platform:generate-urls --dist-type=github --repo-path=vendor/repo --platforms=linux-x86_64,darwin-arm64,windows-x86_64
```

Or with a custom URL template:

```
composer platform:generate-urls --dist-type=https://cdn.example.com/vendor/repo/release-{version}-{platform}.{ext} --platforms=linux-x86_64,darwin-arm64
```

Command options:

- `--platforms` platform identifiers (repeat the flag or use comma-separated values)
- `--dist-type` `github`, `gitlab`, `huggingface`, or custom template
- `--repo-path` repository path for built-in templates
- `--extension` force archive extension

The command writes generated URLs into `extra.artifacts`.

Testing
-------

[](#testing)

Run tests with:

```
composer test
```

The test suite includes:

- unit tests for matching, templating, and generation logic
- integration tests that run real `composer install` flows

License
-------

[](#license)

MIT. See [LICENSE](https://github.com/codewithkyrian/platform-package-installer/blob/main/LICENSE).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~49 days

Total

8

Last Release

69d ago

Major Versions

1.1.4 → 2.0.02026-03-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/146c2eb02350558d165083e0018f5377f15f0e71493439c93ee60e7c7ac97fc1?d=identicon)[CodeWithKyrian](/maintainers/CodeWithKyrian)

---

Top Contributors

[![CodeWithKyrian](https://avatars.githubusercontent.com/u/48791154?v=4)](https://github.com/CodeWithKyrian "CodeWithKyrian (17 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (2 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/codewithkyrian-platform-package-installer/health.svg)

```
[![Health](https://phpackages.com/badges/codewithkyrian-platform-package-installer/health.svg)](https://phpackages.com/packages/codewithkyrian-platform-package-installer)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21764.8M1.6k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M195](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k44](/packages/friendsoftypo3-content-blocks)[altis/local-server

Local Server module for Altis

18217.0k2](/packages/altis-local-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
