Drupal – Composer as Dependency Manager

Posted by Rahul Patel | September 1, 2017

In this blog, We will outline use of composer as a dependency manger for Drupal modules and themes.

Below command is used for downloading modules at the root folder of your Drupal installation

$ composer require drupal/<MODULE_NAME>

You can use either the project name, or the specific module name within a project when requiring a module. Composer will download the whole project that contains a particular module.

You can also download specific version of module, For that use below command

$ composer require drupal/<MODULE_NAME>:<VERSION>

By default Composer downloads all packages in “Vendor” folder, but most of the time we want to download modules, themes and libraries to respective folders.

To overcome this problem, you need to update composer.json located at root folder

"extra": {
    "installer-paths": {
        "core": ["type:drupal-core"],
        "libraries/{$name}": ["type:drupal-library"],
        "modules/contrib/{$name}": ["type:drupal-module"],
        "profiles/contrib/{$name}": ["type:drupal-profile"],
        "themes/contrib/{$name}": ["type:drupal-theme"],
        "modules/custom/{$name}": ["type:drupal-custom-module"],
        "themes/custom/{$name}": ["type:drupal-custom-theme"]

From Drupal 7, it supports composer search function as well, So you can search from drupal modules using command line, for this you can use below command

$ composer search <MODULE_NAME>

reference :- https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies


Add a comment

*Please complete all fields correctly

Related Blogs

Posted by Rukmi Patel | December 2, 2019
iTreeni Technolabs Outshines at GoodFirms by Providing End-To-End Business Solutions
Empowering clients' business by leveraging technology-enabled solutions endows iTreeni Technolabs to tap into the list of top web development companies in Australia at GoodFirms. View iTreeni Technolabs' GoodFirms' profile to...
Posted by Rukmi Patel | April 9, 2019
Comparing Full Stack V/S MEAN Stack approach
The web and mobile app development services have stepped up to next level in last 5 years. Web and apps are all built utilizing a ‘stack’ of various technologies like...
Posted by Rukmi Patel | September 6, 2018
Headless Drupal or DeCoupled Drupal
Now a days, front-end technologies like Angular, React.js, Backbone.js etc have started attracting audience because of its advantages over traditional rendering approach. Server side frameworks like Laravel, Node.js have already...