I have planned to use Composer to manage Drupal core and third-party modules instead of pushing everything to Git and I am using drupal-composer/drupal-project to achieve it.

After running composer create-project drupal-composer/drupal-project:7.x-dev d7 --stability dev --no-interaction, a d7 directory is created with some other directories, including the following ones.

  • vendor
  • web (It contains the Drupal core files.)

Its composer.json file is enough to install the same dependencies in another server, but if I use composer install in my server, how can I checkout my custom modules?

If I add custom modules and the composer.json file only in my repository, where do the custom modules go when I run during composer install? Do they go in sites/all/custom or the root directory?

Is there any other option available to manage my custom modules with Composer?

  • What does "custom module" mean? The contributed module from drupal.org or the module that you create yourself.
    – Thew
    Commented Dec 28, 2016 at 6:27
  • modules that are created by myself.
    – Manikandan
    Commented Dec 28, 2016 at 6:31
  • I'm on the same page and found this for a starting point: drupal.org/docs/develop/using-composer/…
    – Jakub Mroz
    Commented Apr 25, 2018 at 6:54

1 Answer 1


The contributed modules are in web/sites/all/modules/contrib/.

So, the suggested directory for the custom modules is web/sites/all/modules/custom/.

The other way to manage custom modules is to separate repository for the custom modules.

You can add your custom repositories to your composer.json in project root directory. Composer will look in all your repositories to find the packages your project requires. See Use PHP composer to clone git repo. Add your repositories under default Drupal.

After you add your repository to composer.json you have to tell Composer to install your custom modules to web/sites/all/modules/custom/. Add this line to installer-paths

"web/sites/all/modules/custom/{$name}/": ["type:drupal-custom-module"],

When you create your custom module, you must set type of your custom module in composer.json to drupal-custom-module.

  • Thanks for your reply. But it will need two repo to maintain changes in composer json and custom modules. right? Because if i use git repo only for my custom modules, then updates in composer has to be tracked in another repo as that file will be used in server using install command. Please correct me if I am wrong?
    – Manikandan
    Commented Dec 28, 2016 at 9:11
  • 1
    Yes, composer file in site root needs to be tracked. These are same steps as installing contributed module. Additions are adding your own repo and custom modules directory.
    – Thew
    Commented Dec 28, 2016 at 12:18

Your Answer

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

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