codewithkyrian/platform-package-installer
The Composer Platform Package Installer is a powerful plugin for platform-aware distribution URL resolution.
The core behavior is simple:
composer.json{version} plus optional custom variables)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"
}
}
All core behavior is configured in composer.json under extra.artifacts.
Legacy extra.platform-urls is still supported for backward compatibility, but is deprecated.
Use this when:
{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"
}
}
}
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"
}
}
}
}
Consumers of your platform package can override variables from their root project:
{
"extra": {
"platform-packages": {
"org/your-platform-package": {
"runtime": "cpu"
}
}
}
}
Variable precedence:
extra.platform-packages.<package-name>)extra.artifacts.vars){version} (always provided by plugin){version} is built in and always available{name} placeholder can be useddist configurationThe plugin matches the current machine against keys in artifacts:
linux, darwin, windows, raspberrypidarwin-arm64, linux-x86_64, windows-32, windows-64, etc.all as final fallbackMore specific matches are preferred over generic ones.
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 extensionThe command writes generated URLs into extra.artifacts.
Run tests with:
composer test
The test suite includes:
composer install flowsMIT. See LICENSE.
How can I help you explore Laravel packages today?