What are Drupal modules?
In Drupal, certain functionalities are provided in so-called modules. The core system of Drupal 10, also known as Core, has 52 modules. These provide the basic functions and also extend the range of functions with optional modules (such as a forum).
If these are not enough, you can help yourself from the Drupal community and thus expand the possibilities of the system almost endlessly.
With a total of over 50,000 modules provided (so-called contrib modules) and more than 6,200 compatible modules for the current version 10 (as of 7.9.2023), Drupal allows us to build and customize a website according to our own ideas using existing modules and themes alone. The globally active Drupal community ensures that these extensions are always updated and kept secure.
Nevertheless, there are of course always requirements that are not covered by a contrib module. This is where custom modules come into play. These modules are programmed with PHP and extend Drupal as required. You can find out what custom modules are or how to create your own modules in our blog article"Two easy ways to create a Drupal module".
How to install a Drupal module
Installing a Drupal module is done in three steps: search for module, integrate module and install module. These are described in detail below:
Step 1: Search for a module
You can find a list of all available modules on the module page on drupal.org. Call up the module overview on drupal.org here.
Here you can search for specific modules, but also discover completely new ones: e.g. there is an overview of the modules that have been downloaded or installed most frequently by the Drupal community. Once you have landed on the module page of a desired module, you will find a short summary of the module, links to documentation, statistics and further information.
Once you have found a suitable module, continue with step 2: Integrate module. In our example, we use the very frequently used "Token" module.
Once you have landed on the module page of a desired module, you will find a brief summary of the module, links to documentation, statistics and further information.
Once you have found a suitable module, continue with step 2: Integrate module. In our example, we use the very frequently used "Token" module.
Step 2: Integrate module
In the lower section of the Token module page, you will find the available releases separated by main version. Only use versions with a green background. If the background is yellow, you should first check the release notes to find out whether it is safe to use on your site. You can find these by clicking on the blue version number at the top left of the box.
Also look for the shield icon next to the version number before downloading a module. These security advisories are managed by the Drupal Security Team and mark modules that are compliant or non-compliant with the security standards.
Once you have selected the desired version, you have two options for integrating the desired module into your Drupal 10 installation:
Integration with Composer (recommended)
Composer is a dependency manager (package manager) for PHP, which takes care of resolving dependencies and automatically downloading all required libraries in the configured version into your project. If Composer is not yet installed on your system, you can find instructions for Linux here. Contrib modules provided by the community can often have multiple dependencies. Without Composer, you would have to take care of all dependencies when downloading the modules. Downloading via Composer is the recommended way by Drupal. For more information on how to use Composer with Drupal, click here.
The following command on the command line can be used to install modules with Composer.
composer require drupal/module_name
Copy the command next to "Install" at the end of your module page in the "Releases" area and execute it. For example, to download the "Token" module, execute the following command:
composer require 'drupal/token:^1.12'
If you do not want to download the latest version of a module, but a specific version, you can specify the version as follows:
composer require 'drupal/module_name:version'
Further information on this can be found here under "Specifying a version".
When you execute the desired command, a new "token" folder is automatically created in "modules/contrib" and the module is now available for activation in the list of all available modules. Please note that this command only downloads modules, but does not activate them!
Manual integration
To obtain a manual download link, click on the blue version number in the top left-hand corner of the box. On the following page, click on the desired link in the "Alternative installation files" section.
Integrate into Drupal
Once you have successfully downloaded the module, unzip it and you will receive a folder named after the module. The folder must now be integrated into Drupal. To do this, move this folder to your project directory. Modules provided by the Drupal community are stored in the path "modules/contrib" by default. In our example, the directory path must therefore be modules/contrib/token.
Step 3: Install the module
After you have integrated the module code into your Drupal installation, you still need to install the module. There are also two ways to do this.
Installation via the backend
Go to "Extend " in the admin area of your site. There you will see a list of all the modules that are available to you. In addition to a short description of the module, you will also receive information about the version of the module, "requirements" (dependencies of modules), or you can go directly to the module configuration.
To install, select the checkbox next to the module name "Token" and then click on the Install button at the bottom of the page. Done.
Installation with Drush
A module can also be activated via drush. Drush stands for Drupal Shell and is a terminal tool for managing Drupal websites. Drush makes it possible to carry out a variety of administrative tasks directly in the command line. This not only saves a lot of time, but also allows the developer to concentrate on their work without being distracted by switching back and forth between the terminal and the user interface. To activate a module with drush, execute the following command:
drush en module_name
To switch on the "token" module, for example, execute the following command:
drush en token
CONCLUSION
We hope that this article has shown you various ways and tools to help you successfully download and install a module.
Even though we have already mentioned that Composer is the way recommended by Drupal to manage dependencies of modules and other extensions, the manual way remains open, of course.
Are you still working with an outdated Drupal version? We offer an upgrade service, find out more: Drupal 10 Upgrade