Chapter 1: Introduction to Drupal Module Development

This chapter is part of the Drupal Module Developer Guide.

This chapter starts by explaining what modules are and the role they play in a Drupal application. Then introduces new module developers to essential tools and resources. The chapter ends with 2 tutorials that walk through setting up everything required to be able to follow along with the coding challenges in the rest of the guide.

Tutorials in this course
Categories
Drupal 8, 9, and 10
More information

Modules enable developers to customize Drupal without modifying the core software. To ensure a stable and upgradeable core system, Drupal defines integration points and patterns that developers can use to customize the system. Modules contain code (PHP, JavaScript, Twig, CSS, YAML, etc.) that can extend, alter, and enhance Drupal's features and functionality.

In this tutorial, you'll learn:

  • What Drupal modules are and their role in Drupal architecture
  • How modules interact with Drupal core to extend or alter site functionality
  • About the types of modules: core, contributed, and custom

By the end of this tutorial, you should be able to explain what modules are in Drupal, and understand their role in defining a Drupal site's functionality.

More information

One of the primary ways that modules extend Drupal is by adding dynamic pages with content generated by application-specific logic. This tutorial looks at Drupal's process of handling a user's request and transforming it into a complete web page. We'll answer questions like:

  • How does Drupal use Symfony's HttpKernel to process requests?
  • How do user-configured blocks and the theme layer contribute to the page's content and appearance?
  • What is the role of routes, controllers, and responses in this process?

In this tutorial, we'll:

  • Follow the journey of a user request from URL to an HTML response in Drupal.
  • Define the role of routes, controllers, and responses in Drupal's request handling.
  • See how blocks and the theme layer contribute to the final output of a Drupal page.

By the end of this tutorial, you should be able to describe Drupal's request flow, understand the interaction of its key components in building a page, and appreciate the modular architecture that drives Drupal's flexibility.

More information

To become an effective module developer, you'll need to know how to navigate and use Drupal's extensive documentation. In this tutorial, you'll learn about the types of documentation available to Drupal developers, including API references, community-contributed documents, and best practices for using these resources.

More information

A development environment is any copy of your site that operates separately from the live site. Development environments allow you to make changes, try new modules, write new code, and test new ideas on a copy of your site instead of the real thing. Using a development environment ensures any changes you make happen in a sandbox where you’re not affecting anyone trying to use the live version of your application. As a module developer, it's common practice to set up a copy of your Drupal application on your own computer for development and testing purposes.

In this tutorial we'll learn:

  • What a development environment is and why it's needed
  • The specific requirements for Drupal, and a recommendation (DDEV) for those seeking a straightforward solution
  • Other commonly-used extras that enhance the development experience

By the end of this tutorial you should be able to describe the requirements of a Drupal development environment and know how to get started setting one up for yourself.

More information

There are a number of tools that help make your Drupal development experience enjoyable and efficient. They aren't required, only recommended. We'll introduce 5 tools: PhpStorm, Devel, Xdebug, Drush, and the Stage File Proxy module. Each tool serves a unique purpose, from streamlining coding processes to improving local site performance.

In this tutorial we'll learn:

  • The purpose and benefits of using PhpStorm in Drupal development.
  • How Devel provides valuable debugging and development assistance.
  • The role of Xdebug in code debugging and analysis.
  • The importance of Drush for command-line site management.
  • How the Stage File Proxy module optimizes local development environments.

By the end of this tutorial, you should be able to understand how these tools contribute to the Drupal module developer experience.

More information

To follow along with the examples in this guide you'll need to have a copy of the Anytown Farmer's Market site that resembles what you would have if you went through all the chapters in the Drupal User Guide. If you did not follow along with the Drupal User Guide example, or if you need a fresh start, this tutorial will walk you through setting up a copy of the site based on a backup. This guide follows a project-based learning approach, and this setup is essential for ensuring that you can effectively follow along with the subsequent tutorials.

In this tutorial, we'll:

  • Locate the codebase, backup database, and backup public files directory, required to restore a copy of the Anytown Farmer's Market site.
  • Walk through setting up the site in DDEV using the provided backup.

By the end of this tutorial, you should have a working copy of the Anytown Farmer's Market site on your local development environment.

Categories
Drupal 8, 9, and 10
More information

Drush, the Drupal Shell, is a utility for module developers and administrators. While it does ship with DDEV, it doesn't come standard with Drupal core and must be installed separately via Composer.

In this tutorial we'll:

  • Install Drush with Composer
  • Verify that Drush is working

By the end of this tutorial, you should have a working copy of the Drush utility installed in your development environment.

This course appears in the following guides:
Module Development
Learn Drupal module development in this hands-on guide.

Drupal Module Developer Guide