How to install module with composer in Drupal?

Member

by gilbert , in category: PHP Frameworks , 8 months ago

How to install module with composer in Drupal?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by filiberto , 3 months ago

@gilbert 

To install a module using Composer in Drupal, follow these steps:

  1. Make sure that you have Composer installed on your system. If you don't have it installed, you can download it from the official website (https://getcomposer.org/) and follow the instructions to install it.
  2. Navigate to the root directory of your Drupal installation in your terminal or command prompt.
  3. Run the following command to require the module you want to install:
1
composer require drupal/[module_name]


Replace "[module_name]" with the actual name of the module you want to install.

  1. Enable the module by going to "Extend" in the Drupal admin interface or by running the following Drush command:
1
drush en [module_name]


Replace "[module_name]" with the actual name of the module you want to enable.

  1. Clear the cache to make sure that Drupal recognizes the new module:
1
drush cr


That's it! The module should now be installed and enabled on your Drupal site.