I installed Drupal 8, and for the Panels module, I had to install the following other modules manually:
- Page Manager
- Layout
- Chaos tools suite
Can we use composer to install modules with their dependencies?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI installed Drupal 8, and for the Panels module, I had to install the following other modules manually:
Can we use composer to install modules with their dependencies?
Yes, you can. I just set this up today; it took about two hours. Here are my notes.
This blog post explains the basics. And this post explains about patching.
In short, this is what you need to do for the composer.json in your drupal root:
Add these lines to use Drupal Packagist:
"repositories": [
{
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}
],
Under "require"
, add your modules:
"require": {
"drupal/address": "8.1.0-beta2",
"drupal/advagg": "8.2.0-beta2",
"drupal/cloudflare": "8.1.0-alpha1",
"drupal/commerce": "8.2.0-alpha2",
"drupal/email_registration": "8.1.*@dev",
For how to specify versions, see the Drupal Packagist page.
If you will be using module patches, you also need to add the patch library under "require"
:
"cweagans/composer-patches": "~1.0",
And specify the patches under "extra"
like this:
"patches": {
"drupal/smtp": {
"Does not set as default system on enable" : "https://www.drupal.org/files/issues/smtp-enabling_module_does-2651976-19.patch",
"Remove install config" : "https://www.drupal.org/files/issues/remove_install-2651434-2.patch"
}
}
Then run:
composer update
But, you might get a ton of errors about it not being able to handle drupal core. This happens if a module depends on core. To fix this, at the top of composer.json, add the Drupal core version number like this:
"version": "8.0.3",
Don't forget to update this number when you update core.
See this composer template for Drupal project for an example of how this works. Usage:
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
With composer require ...
you can download new dependencies to your installation.
cd some-dir
composer require drupal/devel:~1.0