Install the Module within Drupal

Create the Module’s Module File

The module’s module file contains code which is loaded into Drupal each time a user accesses the Drupal site.

The module file will contain Drupal hooks which are functions that execute when some predefined event happens on the Drupal
site (e.g., a new node is inserted, content is updated, a user logins to the system). Drupal hooks are similar to Drupal
rules but at the programming level rather than the user interface level.

You can also include code that is shared among the module’s controllers in the module file. The module file is loaded each
time a Drupal site is accessed. I believe the controller code is loaded only when that controller is needed to run. Thus,
it is more efficient to put code in the controller files that is specific to the controller’s functionality.

We’re going to start by creating code to display a list. We’ll add a function to the module file that will eventually make
that happen.

create <site>/modules/custom/lists/lists.module

<?phpfunctionlists_display_list() {
return t('Display List');
}

Model-View-Controller (MVC)-based Applications

Drupal is a Model-View-Controller (MVC)-based application.

The Model represents the underlying data that the application operates against.

The View defines the user interface to the application.

The Controller is the workhorse of the applications, including routing requests from users and returning information to
the view to display to the user.

Create the Module’s Routing File

The routing file defines how a visitor will access the functionality of our module, as defined by the controller, and returns the values to be displayed.