Creating a module
The first step to extend Drupal is to create a custom module. Although the task sounds daunting, it can be accomplished in a few simple steps. Modules can provide functionalities and customizations to functionalities provided by other modules, or they can be used as a way to contain the configuration and a site's state.
In this recipe, we will create a module by defining an info.yml
file, a file containing information that Drupal uses to discover extensions, and enabling the module.
How to do it...
- Create a folder named
mymodule
in themodules
folder in the base directory of your Drupal site. This will be your module's directory. - Create a
mymodule.info.yml
file in your module's directory. This contains metadata that identifies the module to Drupal. - Add a line to the
name
key to provide a name for the module:
name: My Module!
- We will need to provide the
type
key to define the type of extension. We provide themodule
value:
type: module
- The
description
key allows you to provide...