2

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?

  • 1
    Not sure, but you can definitely use Drush to do it – Clive Nov 23 '15 at 13:52
2

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.

| improve this answer | |
2

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
| improve this answer | |
  • OK...Great.. But is it authorized distribution from drupal.org ? – harish Nov 25 '15 at 5:57
  • 1
    It downloads modules from Drupal.org, yes. This is a temporary solution, as the Drupal association is working with the maintainer of packagist.drupal-composer.org to move that functionality directly into Drupal.org. For now, this is the solution that the community is using. – cweagans Nov 25 '15 at 6:13
  • Furthur there is post install hook to .sh file it failed on my windows machine....May be bug to be fixed.. Anyways Thanks very much... – harish Nov 25 '15 at 6:22
  • Yes, there is a bash script. You might need to modify it to work on Windows. Perhaps you can rewrite it in PHP. You can mimic the composer.json in your own project without using that project template though. The important part is the Drupal Composer packagist repository. – cweagans Nov 25 '15 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.