Basic module building tutorial: Lorem ipsum generator

Step-by-step guide for building a module called Lorem ipsum that generates placeholder blocks of random text. This guide walks developers through the motions of writing:

  • The basic structure;
  • Config sync;
  • Settings form;
  • Controller;
  • Services;
  • A block;
  • Theming; and
  • Testing.

Tutorial introduction

What to expect from this guide.

Basic structure

Starting point.

Settings Form

How to make changes that are written to the Database.

Defining a block

Leverage the Plugin API to define a custom Block.

Theming

How to implement theming for a custom template.

Testing a Drupal module

Now for some QA: let's check that our module works as expected.