Guide

Develop Drupal Sites for Drupal 7, 8, 9, and 10

Develop Drupal Sites

Interested in taking the Acquia Certified Developer Exam?

Go to study guide

What will you learn

  • Alter and extend Drupal through plugins, hooks, and events
  • Create or alter forms and their workflows
  • Work with useful objects called services
  • Present content for display using the Render API
  • Utilize Drupal's menu and navigation system
  • Write secure code

Overview

Developers, also known as engineers or programmers, use their knowledge of PHP, MySQL, HTML, JavaScript, and CSS to extend, alter, and enhance Drupal by creating modules. One of the more common tasks that developers do is to create “glue-code”: modules that make minor alterations to the way an existing module works that are application-specific, or modules that tie existing modules together in a unique way, without modifying the original code.

When creating solutions to meet their specific use case, developers do so with an eye towards creating reusable tools when possible, and/or collaborating with other developers to enhance existing tools that are close to, but not quite, the solution needed.

Developers are generally expected to be proficient with Drupal site building, and to know how to leverage the ecosystem of existing contributed modules and Drupal core APIs in order to prevent duplication.

PHP is the programming language in which Drupal software is written, so you should be comfortable with it before diving in. The latest version Drupal is largely written using object-oriented programming (OOP), while Drupal 7 was written primarily using procedural programming, though you'll encounter a smattering of object-oriented elements there as well. As you learn to develop modules for Drupal, you’ll use a combination of PHP fundamentals combined with Drupal-specific functions and APIs.

Drupal 9/10

Background and prerequisites

Coding

Drupal 8, 9, and 10
More information

YAML, which stands for YAML Ain't Markup Language, is a human-readable data serialization format that's been widely adopted in a variety of use cases in Drupal. Anyone wanting to write modules, or themes, for Drupal will need to understand YAML syntax. Even site builders are likely to encounter YAML at least in passing as YAML is the data-serialization format of choice for Drupal's configuration management system. Good thing it's pretty easy to learn even with the most basic of programming backgrounds.

This tutorial will look at the YAML data format and provide examples of how to write and read YAML. Starting with an introduction to the language's syntax and some of the strengths of YAML. Then looking at the difference between scalar data types like strings and integers, and collection data types like lists and associative arrays.

Since YAML in the Drupal world is read into PHP and ultimately becomes a PHP data structure that we can use in our own code we'll also look at how the YAML we write in a .yml file is represented in PHP data types. To do this we'll use the YAML Sandbox module that provides a handy textarea into which we can type YAML and have it parsed into PHP data structures.

Learning objectives

  • Explain what YAML is and its strengths as a data serialization format
  • Create scalar key/value pairs in YAML
  • Create lists, and associative arrays using YAML collections
  • Understand how the YAML you write is represented in PHP

Tips

  • In Drupal, use the .yml extension and not .yaml
  • Ensure your code editing application is configured to use spaces (preferably 2 spaces, as per Drupal coding standards), not the tab character when the TAB key is pressed. If you have tab characters in a YAML file within a Drupal environment, a fatal PHP error will be thrown and you'll see a White Screen of Death (WSOD).
  • Copy and paste from an existing YAML file to ensure the formatting is correct, and edit from there.

Additional resources

Categories
Drupal 8, 9, and 10
More information

Object-oriented PHP utilizes classes and objects to organize code into reusable chunks. This approach helps us organize complex applications, such as Drupal, into modular code called classes that can be reused across the entire system.

Local development set up

Developers are expected to know how to work on a copy of the live site, instead of making potentially hazardous changes or testing new ideas directly on the live site. You should be able to set up a development environment for your work.

Drupal 7, 8, 9, and 10
More information

Development environments provide a sandbox where you can work on your application without affecting the live site.

Tools

More information

The Git version control system can help you keep track of changes in your codebase and make sure you don't unintentionally lose work.

More information

Composer is the preferred dependency management solution for PHP, is used by Drupal core, and is becoming increasingly popular for managing the modules and themes used for a Drupal project.

More information

Drush is a command line interface that enables you to interact with your Drupal site without clicking around the graphical user interface (GUI).

Essential lessons

Developers will need to know how to create new Drupal modules--bundles of PHP code that extend, alter, or otherwise enhance Drupal’s functionality. This requires knowledge of Drupal’s system to allow your custom code to interact with existing functionality. You'll also need to get familiar with the suite of APIs that make up the Drupal framework, many of which exist to ensure you don’t have to rewrite the same code over and over. These essential lessons will give you an overview of what Drupal is doing "under the hood". Dive in to an individual topic and explore related tutorials to understand how to leverage it in your custom module.

Introduction

More information

In this tutorial we're going to look at one the first files you will need in order to create a Drupal module: the info file. Each module is required to have a MODULE.info.yml file to help Drupal identify that a bundle of code is a unique module. This specially-formatted YAML file not only tells Drupal about the module, but also allows us to provide other useful metadata. In this tutorial, we'll walk through all of the metadata possibilities that can be included in an info file.

More information

If you've ever built or administered a Drupal site, the permissions page (/admin/people/permissions) is probably quite familiar.

If you're new to module development, you may wonder where these permissions come from, and how you can specify your own permissions. In this tutorial we'll answer those questions.

First, we'll look at how to define permissions from within a custom module. We'll examine techniques that enable you to provide specific (static) permissions as well as dynamic permissions, which depend on another piece of data, such as the name of a content type. By the end of this tutorial you will understand how to add both static and dynamic permissions to a custom module.

Categories
Drupal 8, 9, and 10
More information

Drupal provides module developers several different methods for creating the different types of links we see on a typical page. In this tutorial we'll see how these different types of links relate to each other, and when you might want to make use of them.

Link types illustrated

In this tutorial we'll provide an overview of the following concepts:

  • Menu links
  • Action links
  • Local tasks
  • Contextual links

APIs and Systems

Categories
Drupal 8, 9, and 10
More information

The Drupal plugin system allows a particular module or subsystem to provide functionality in an extensible, object-oriented way. The controlling module defines the basic framework (interface) for the functionality, and other modules can create plugins (implementing the interface) with particular behaviors. Plugins are grouped into plugin types. Each plugin type is managed by a plugin manager service, which uses a plugin discovery method to discover provided plugins of that type and instantiate them using a plugin factory.

The system aims to make it easy for developers to allow for management of these components via the user interface, giving more flexibility and control to site administrators.

In this tutorial we'll take a high-level look at the problem the Plugin API is solving and provide a starting point for diving deeper into the various components that make up the Plugin API.

Categories
Drupal 8, 9, and 10
More information

Hooks allow modules to alter and extend the behavior of Drupal core, or another module. They are one of the various ways that code components in Drupal can communicate with one another. Using hooks a module developer can change how core or another module works -- without changing the existing code. As a Drupal developer, understanding how to implement and invoke hooks is essential.

In this tutorial we'll:

  • Define what hooks are and the types of hooks that exist
  • Understand the use case for hooks
Categories
Drupal 8, 9, and 10
More information

Drupal uses events to allow modules and various subsystems to communicate with one another in an object-oriented manner. Understanding how the Event API works is critical knowledge for all module developers. In this tutorial we'll:

  • Explain what events are
  • Discuss the use case for subscribing to events
  • Give an example use case for dispatching events

By the end of this tutorial you should be able to explain what events are, understand when to use them in your own code, and know where to learn more about how to do so.

More information

It's best practice to access any of the services provided by Drupal via the service container to ensure the decoupled nature of these systems is respected. In order to do so, you need to know what services exists, and then, where possible, use dependency injection to use them in your code.

This tutorial walks through the process of:

  • Discovering existing services and learn their machine name
  • Using the machine name of service to request a copy from the service container
Drupal 8, 9, and 10
More information

The Render API consists of two parts: structured arrays that provide data and hints about how that data should be rendered, and a rendering pipeline that can be used to render these arrays into various output formats. Understanding at least the basics of how the Render API works, the difference between elements and properties, and the concept of callback functions is an integral part of learning Drupal.

In this tutorial we'll:

  • Look at the fundamentals of the Drupal Render API
  • Point to additional material to provide more detail about the inner workings of the Render API and how content is output in Drupal
Drupal 8, 9, and 10
More information

The core structure of Drupal's Render API is the render array, which is a hierarchical associative array containing data to be rendered and properties describing how the data should be rendered. As a module developer you'll use render arrays to describe the content your module controls in order to output it on a page as HTML, or as part of a response in another format like JSON. As a theme developer, you'll manipulate render arrays in order to affect the way content is output on the page.

In this tutorial we'll learn:

  • What render arrays are and why they exist
  • The basic format of a render array
  • What "properties" and "elements" signify in the context of a render array
  • Where to find more information about how to create a render array to describe your own content

By the end of this tutorial you should be able to understand when you need to use a render array, recognize one when you see it, and know where to get more detailed information about render array formatting specifics.

Categories
Drupal 8, 9, and 10
More information

If you've ever created or edited a piece of content on a Drupal site you have already interacted with the Field API. The Field module (along with its user interface counterpart) is responsible for providing the forms and data components used to build up the content model that make up a Drupal site. Understanding how Drupal fields work and how they're constructed via the Field API is an important part of understanding how Drupal works.

In this tutorial, we're going to look at the main components that make up the Field API at a high level. We'll see how the Field UI module exposes the field types included in core. We'll also look at the three main pieces that compose fields: types, widgets and formatters.

Drupal 8, 9, and 10
More information

One of the central components of Drupal's Render API is render elements. You can think of them as prepackaged render arrays or shortcuts you can use to describe common things, like tables, links, and form elements, in a consistent way. In this tutorial we'll take a more in-depth look at the use of the #type property in render arrays in order to answer questions like:

  • What are render elements, and what is their use case?
  • Where can I find more information about available element types?

By the end of this tutorial you should be able to identify individual render element types within a larger render array, find the relevant documentation for specific types of render elements, and explain the use case for render elements.

Categories
Drupal 8, 9, and 10
More information

Many of the processes that Drupal performs when responding to a request are cached in order to increase performance. Creating the HTML for the page that a user sees or the JSON response to a REST request can require thousands of operations. Some operations are time consuming, memory heavy, CPU intense, or all 3. By performing the operation once, and then caching the result for next time, subsequent requests can be fulfilled faster. In order to make it easier to store, retrieve, and invalidate cached data, Drupal provides cache-related services you can use in your code. Drupal also enables you to provide information about the cacheability of data to the Render API to improve the performance of page rendering.

In this tutorial we'll:

  • Cover the terms and concepts you should be familiar with when working with the Cache API
  • Point to additional resources for more information about how to perform specific tasks with the Cache API

By the end of this tutorial, you should be able to define the concepts of bubbling and cache invalidation, and know how cache keys, tags, context, and max-age are used to provide cacheability metadata for items.

Categories
Drupal 8, 9, and 10
More information

Drupal's Form API is a set of interfaces, utility classes, and conventions that when combined together allow module developers to create forms that collect, validate, and process user-submitted data. The Form API is closely related to the Render API. It uses Render Arrays to define forms, and adds an additional level of workflow and processing to enhance the Render API with some features specific to handling forms.

Given that forms are one of the primary means of interacting with a Drupal site via the UI, understanding how the Form API works is a critical part of learning to develop modules for Drupal. While you may not need to know all the nitty-gritty details, every Drupal module developer is likely to encounter aspects of the Form API at some point. Understanding the basics should be considered required knowledge.

Theme developers are also likely to encounter some aspects of the Form API, as forms are inherently part of the look and feel of a site. Knowing how to make changes to the UX of a form is an important skill.

In this tutorial we'll:

  • Describe what forms are and how they are used in Drupal
  • Explain the relationship between Form API and the Render API
  • List some of the benefits of using the Form API over generic HTML forms

By the end of this tutorial you should have a solid understanding of the role of the Form API in Drupal.

Categories
Drupal 8, 9, and 10
More information

When learning Drupal development, it won't be long before you encounter the word "entity" and the Entity API. But what are entities in Drupal? How can you use them to build your site? When should you use the Entity API?

This tutorial will explain Drupal's Entity system from a high level. We'll look at:

  • The main problems the Entity system solves
  • Key terms you should know
  • Key concepts we'll explore as we dive into Drupal's Entity API

By the end of this tutorial you should be able to explain the problems that the Entity API solves, and when you should use it in your own code.

Categories
Drupal 8, 9, and 10
More information

Drupal's configuration system helps to solve the problem of moving changes in configuration from development to production. It does this in two ways: by providing a unified way to store configuration and by providing a process by which configuration changes can be imported and exported between instances of the same site. The configuration system is the result of work completed within the Configuration Management Initiative (CMI).

In this introduction, we'll provide:

  • An overview of Drupal's configuration system
  • Key concepts that you should know about
Categories
Drupal 8, 9, and 10
More information

Configuration entities are suitable for creating user-defined configuration, such as image styles, views, content types, etc. A configuration entity type is defined by a module, default configuration is provided by that module as well as any other module, and then users can create zero or more configuration entities through Drupal's administrative UI.

In this tutorial, you will learn about:

  • What configuration entities are
  • Configuration entity types versus configuration entities
  • An example in core: image style
  • Overview of the process of creating your own configuration entity types in a module
More information

The process for keeping Drupal core and contributed modules and themes up to date with the latest security and minor version releases.

Drupal 7, 8, 9, and 10
More information

Coding standards provide a set of rules for how your code should be formatted, and best practice guidelines for naming conventions and the location of files.

Advanced concepts

Dive deeper into the systems, APIs, tools, workflows, and best practices of Drupal development.

Categories
Drupal 8, 9, and 10
88 tutorials
Tutorials in this course
Categories
Module Development, Backend and Infrastructure
Drupal 8, 9, and 10
Drupal 7, 8, 9, and 10
More information

Debugging is the practice of troubleshooting an application through the use of tools and processes in order to find and fix bugs, or better understand the underlying code.

Drupal 7

Background and prerequisites

Coding

PHP

Topic
Drupal 7, 8, 9, and 10
More information

PHP: Hypertext Preprocessor (PHP) is a popular interpreted programming language that is especially suited for web development. Drupal core and all contributed modules are written in PHP.

Local development set up

Developers are expected to know how to work on a copy of the live site, instead of making potentially hazardous changes or testing new ideas directly on the live site. You should be able to set up a development environment for your work.

Drupal 7, 8, 9, and 10
More information

Development environments provide a sandbox where you can work on your application without affecting the live site.

Tools

More information

The Git version control system can help you keep track of changes in your codebase and make sure you don't unintentionally lose work.

More information

Drush is a command line interface that enables you to interact with your Drupal site without clicking around the graphical user interface (GUI).

Drupal 7, 8, 9, and 10
More information

Development environments provide a sandbox where you can work on your application without affecting the live site.

Essential lessons

Drupal 7, 8, 9, and 10
More information

Coding standards provide a set of rules for how your code should be formatted, and best practice guidelines for naming conventions and the location of files.

Advanced concepts

Drupal 7, 8, 9, and 10
More information

Tools and workflows for deploying code and configuration changes from one environment to another with Drupal-specific considerations.

Learning tips

Learning to be a master of Drupal development can be a daunting task, especially when you’re just getting started. There’s a lot to learn, and a lot of the best information is spread out across Drupal.org and various other websites, books, and podcasts. As you’re climbing the ladder and becoming more proficient with Drupal, here are some things to keep in mind:

  • Drupal is open source software, and as such, the code is freely available to read. Looking at how Drupal core or other contributed modules have solved problems similar to yours is a great way to get started.
  • The Drupal API is quite extensive; focus on mastering high-level concepts and terminology first. Don’t try and memorize all the details—instead, use the tools available to look up the documentation and examples for implementation-specific details.
  • Knowing when to write custom code vs. using an existing solution is an important skill.

If you are interested in taking the Acquia Certified Developer Exam, you will also definitely want to work your way through our exam guide.

Broaden your skills

There are many ways to grow your skills and knowledge outside of tutorials. Here are some of our favorite resources for exploring Drupal development.

Contribute to the Drupal project

Although not a requirement, many Drupal developers also enjoy being active members of the Drupal community and contributing their solutions back to Drupal.org in the form of a contributed module, or by helping to resolve bugs in the modules they use, or even in Drupal core itself. Nothing will improve your understanding of Drupal like explaining it to someone else—or taking pieces of it apart and fixing them.

More information

As an open source project, Drupal depends on community contributions in many forms including documentation, code, translation, speaking, organizing events, mentoring others, and even donating money.

Categories
Drupal 7, 8, 9, and 10
More information

Drupal has an amazing community of people who create the software and help each other make the best use of it. This is one of the main benefits of using Drupal — and everyone should take advantage of that.

Community Events

DrupalCon sessions and other local/regional events are a great way to get up to speed on the latest in Drupal development. All DrupalCon sessions are recorded and are available for free on the Drupal Association’s YouTube channel. Many Drupal "Camps" (local or regional Drupal community events) also record sessions. For DrupalCon and many other Drupal events, the recorded sessions are embedded on the session description pages on the event's website.

Meet some developers

Get to know more about what it means to be a Drupal developer through these interviews:

“Drupalize.Me has trained thousands of Drupalistas. Their video lessons help to address our constant need for more Drupal talent. Drupal needs training like this to support its growth.”
Dries Buytaert
Drupal Founder and Project Lead
Photo of Dries Buytaert
“They’re easy to understand. They’re thorough. They’re funny. They’re always entertaining, and it makes it easy to learn parts of Drupal and how you can integrate it into your workflow and learn more and have a good time doing it.”
Roger Carr
Drupalize.Me Member
Photo of Roger Carr
“The mission of the Drupal Association is to foster and support the Drupal software project, the community, and its growth. Drupal education, like that provided by Drupalize.Me, is important to this mission.”
Megan Sanicki
Former Exec. Director, Drupal Assoc.
Photo of Megan Sanicki

FAQs

Am I required to sign a contract?
No. You can purchase a membership and/or cancel any time. Drupalize.Me is a pay-as-you-go service.

Can I preview tutorials before joining?
Yes! Just navigate to our tutorial library. Our free tutorials are labeled with a green "FREE" tag.

Can I watch videos on my mobile device?
Yes! Drupalize.Me is a responsive site and can be accessed in the browser on any mobile device. More FAQs