I have an installation profile with custom modules and themes.

How should I use Composer so that Drupal and the installation profile's dependencies are downloaded and copied in the right directories?

2 Answers 2


You need to use the Composer Manager, which search the composer.json file in any module add the dependency on the core composer.json

How to handle the dependency ? By writing a composer.json file that contains all the php libraries that are been load it.

Here is an example of a good composer.json

  "name": "drupal/mobile_detect",
  "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices.",
  "type": "drupal-module",
  "homepage": "http://drupal.org/project/mobile_detect",
  "authors": [
      "name": "Matthew Donadio (mpdonadio)",
      "homepage": "https://www.drupal.org/u/mpdonadio",
      "role": "Maintainer"
      "name": "Darryl Norris (darol100)",
      "email": "[email protected]",
      "homepage": "https://www.drupal.org/u/darol100",
      "role": "Co-maintainer"
  "support": {
    "issues": "http://drupal.org/project/mobile_detect",
    "irc": "irc://irc.freenode.org/drupal-contribute",
    "source": "http://cgit.drupalcode.org/mobile_detect"
  "license": "GPL-2.0+",
  "minimum-stability": "dev",
  "require": {
    "mobiledetect/mobiledetectlib": "~2.8"

This composer.json is for the mobile_detect drupal module. Once you run the core composer.json this will download the mobile_detect library into the vendor directory and support autoload. And you can do the same thing with your libraries.

For more information about D8 and composer I will recommend reading this article - https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/

  • Is it possible at this time to have a composer for my project that would contain drupal core dependency? So not using drupal directly.
    – user21641
    Dec 10, 2015 at 10:47
  • Yes... but its a best practice to use the root composer.json. If you only want to update/download an specific lib you can always do that. Dec 10, 2015 at 10:51
  • 1
    Composer manager module is deprecated and no longer needed, due to improvements in Drupal 8.1.
    – leymannx
    Jul 28, 2016 at 10:38

It seems composer-manager is deprecated in drupal 8 and composer does not automatically install the profile's dependencies.

Also trying to build the profile's .make files as per this page results in

Make has been removed, in favor of Composer. Use the make-convert command in Drush 8 to quickly upgrade your build to Composer.

It seems there is no clear documentation on how to load dependencies of a profile/distribution.

After reading this issue with comments from some years ago it seems that to this date the only viable option for profiles that have not created their own composer project is to copy the required section from the profile_name/composer.json file and include them in the main composer.json and run

rm composer.lock
composer install

or alternatively just run composer update --with-dependencies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.