Currently I have a composer-based Drupal project with both third-party and custom modules. Third-party modules are managed by composer without any issues. But I would like my custom modules to declare their dependencies in a composer.json
within their directories, and also have them install when I run composer install
at the root of the project.
composer.json
web/
modules/
contrib/
address/
admin_toolbar/
...
custom/
my_module/
composer.json
...
my_other_module/
composer.json
Currently:
- I have the composer merge plugin which works fine for the most part but would like to avoid using it. It has a nasty habit of calling
update
and bumping dependency versions when it shouldn't. - I've already looked into Composer path repositories. While it does install the dependencies of my custom modules, it also symlinks/copies my custom module into
web/modules/contrib
which is unnecessary because the custom modules are already in the right place inweb/modules/custom
.
In the future, I would splinter off these custom modules into their own projects and stored in their own repositories. But for now, they're still housed in the same project as the Drupal site I'm building.
How do I install dependencies declared in the composer.json
of my local custom modules together with everything else?
type
of your custom modules' composer.json files todrupal-custom-module
, and you have a setting in your main composer.json underinstaller-paths
fortype:drupal-custom-module
to go todocroot/modules/custom/{$name}
(recent versions of the core recommended project already have this), the composer path repositories method might work? Hopefully it's smart enough not to try to overwrite the source with itself