webimpress / composer-extra-dependency
Composer plugin to require extra dependencies
Installs: 696 194
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 1
Forks: 2
Open Issues: 2
Type:composer-plugin
pkg:composer/webimpress/composer-extra-dependency
Requires
- php: ^5.6 || ^7.0
- composer-plugin-api: ^1.1
Requires (Dev)
- composer/composer: ^1.5.2
- mikey179/vfsstream: ^1.6.5
- phpunit/phpunit: ^5.7.22 || ^6.4.1
- zendframework/zend-coding-standard: ~1.0.0
This package is auto-updated.
Last update: 2025-10-07 17:41:09 UTC
README
This composer plugin allows you to require composer dependencies in version
specified by user during the installation. It modifies the composer.json file
and add required package in require section.
This can be useful when your library supports multiple version of some dependencies and you'd like to force user to use an explicit dependency instead of depending on implicit dependencies from your library.
Usage
Require the package in your library:
# composer require webimpress/composer-extra-dependency
Update your composer.json file: in section extra.dependency add package(s)
you'd like to install with your library:
{
"name": "my/package",
"description": "This is my package",
"extra": {
"dependency": [
"package/to-require",
...
]
},
"require": {
"php": "^5.6 || ^7.0",
"webimpress/composer-extra-dependency": "^0.1 || ^1.0",
...
}
...
}
Then, during installation of your library, user will be prompted:
# Enter the version of package/to-require to require (or leave blank to use the latest version):
After providing the version, composer.json of the user will be update
(package will be added in require section with version provided by user).
If user does not provide the version, plugin will try to find package in the
latest version matching platform requirements and other dependencies.
Here also composer.json will be updated and package will be installed.
Plugin runs always on post update/install package to check if there are some
dependencies to require explicitly in user composer.json file.
If dependency is already provided in user
composer.json(requireorrequire-devsection) the plugin is not going to do anything.
Please note plugin works only in development interactive mode. It means when
--no-devor--no-interactionflags are provided, plugin is not going to do anything.