I've found Dependencies in a custom module with drupal-composer, How can I include a third party library in my custom module without using Composer Manager and How to manage contrib modules composer dependencies on drupal 8 which are releated to my question, but no longer seem to apply since Drupal 8.1 and the deprecation of Composer manager.
Also popular guides such as The definitive introduction to D8 and Composer appear to no longer apply as they also mention composer manager.
The other solution opposed to composer manager, alter the core composer.json file feels like too much core hacking and would probably break with every Drush update of Drupal core(?).
More specifically, I am attempting to update Views vCards from Drupal 7 to 8. I have created my composer.json file as follows:
{
"name": "drupal/views_vcards",
"description": "Allows creation of vCards using the fields provided by the Views module.",
"type": "drupal-module",
"license": "GPL-2.0+",
"homepage": "https://drupal.org/project/views_vcards",
"require": {
"maennchen/zipstream-php": "0.3.*"
}
}
But if I put a composer.json file in my module folder, how do I make Drupal aware that that file is there, and how do I make sure the required zipstream-php
library is downloaded?
Simply running composer update
from the Drupal root does update a lot of Drupal dependencies, but it does not include the composer.json files that are in the modules folders. I also don't assume I should be calling composer install
from inside all modules with dependencies.
How do I make Drupal aware of a module's dependency without using composer manager and/or hacking core?
UPDATE:
The composer merge plugin used by core appears to have support a wildcard path:
{
"require": {
"wikimedia/composer-merge-plugin": "dev-master"
},
"extra": {
"merge-plugin": {
"include": [
"composer.local.json",
"extensions/*/composer.json" // < ---- THIS LINE
],
"require": [
"submodule/composer.json"
],
"recurse": true,
"replace": false,
"merge-dev": true,
"merge-extra": false
}
}
}
Why doesn't core merge modules/*/composer.json
, that would solve everything right?
Update 2:
THe reasoning for not supporting this is covered in this issue (which also has been quiet for some time now).
composer.json
file is the new recommended way and drush for downloading and installing modules is getting replaced? Obviously will composer automatically resolve nested dependencies and indeed also download my dependencies.