Reputation: 898
I'm working on a project that you can install extensions on, i.e., you install the core program and then you can download and add third-party extensions to it.
If there are two separate extensions that require the same version of the same dependency (for example, if two extensions need the AWS SDK), is there any way to make it so that composer doesn't end up downloading two copies of the same dependency?
Upvotes: 2
Views: 180
Reputation: 389
You can create your extensions as composer packages. Then add to your main composer.json
file references to your own packages.
For example:
root/
my-extension-a/
composer.json ( require: dep-a, dep-b)
vendor/
dep-a/
dep-b/
my-extension-b/
vendor/
dep-a/
dep-c/
composer.json (require dep-a, dep-c)
main-project/
composer.json (require my-extension-a, my-extension-b)
vendor/
my-extension-a/
my-extension-b/
dep-a/
dep-b/
dep-c/
The composer.json
file in your main project will look like this:
"require": {
"parent5446/my-extension-a": "dev-master",
"parent5446/my-extension-b": "dev-master"
}
You can make your extensions public in packagist. Or you can use Satis to reference private repositories. This feature is well documented here: Managing private packages with Satis and Composer
Upvotes: 2