folivoro / composer-dropin-installer
Copies a single file from a package into a target directory defined by installer-paths.
Package info
github.com/folivoro/dropin-installer-plugin
Type:composer-plugin
pkg:composer/folivoro/composer-dropin-installer
Requires
- php: ^8.4
- composer-plugin-api: ^2.0
Requires (Dev)
- composer/composer: ^2.0
- pestphp/pest: ^3.0
README
Folivoro Composer-Dropin-Installer
A Composer plugin that copies files from any installed package into a target directory — either resolved from the root package's installer-paths configuration, or a direct path relative to the project root.
Why
Some packages need to place a file at a specific location in the project — for example, a WordPress MU-plugin bootstrapper or a shared config file. The standard composer/installers approach installs an entire package directory. This plugin does one thing: copies declared files to the right place.
Installation
composer require folivoro/composer-dropin-installer
Usage
In any package that wants to install dropin files, add to composer.json:
Single file (via installer-paths)
{
"extra": {
"dropin": {
"file": "my-plugin.php",
"target-type": "wordpress-muplugin",
"target-dir": "my-plugin"
}
}
}
Single file (via direct path)
{
"extra": {
"dropin": {
"file": "pint.json",
"target-path": "."
}
}
}
Multiple files
{
"extra": {
"dropins": [
{ "file": "pint.json", "target-path": "." },
{ "file": "phpstan.neon", "target-path": "." },
{ "file": "rector.php", "target-path": "." }
]
}
}
The root project must have installer-paths configured when using target-type:
{
"extra": {
"installer-paths": {
"public/extensions/components/{$name}/": [
"type:wordpress-muplugin"
]
}
}
}
Given the above, my-plugin.php will be copied to: