Getting Started - Background & Prerequisites (Drupal 8)

Last updated on
20 February 2018

Drupal 8 leverages a number of advanced PHP language features and sophisticated 3rd party libraries in order to present 3rd party developers with the most advanced API of any CMS available. While experienced Drupal 7 developers may see some significant changes, much of the basic structure will remain familiar.

If any of the material presented while going through the D8 module developer's walk-through is new to you, then the material below may help. However, a comprehensive knowledge is not necessary to proceed to the D8 module walkthrough.

Object Oriented Programming

OOP, while initially daunting, is now well established as a best practice.
For a general overview of PHP best practices, read through Drupal doesn't make use of all the different tools and techniques documented there but it does serve as a great introduction to PHP and the language's many features.

Brush up on your OOP knowledge by reading the official PHP documentation on Classes and Objects as well as some of these other good primers:

Drupal 8 also makes use of some common design patterns and you'll want to make sure you have a basic understanding of these:

PHP Namespaces

If you're unfamiliar with the concept of namespacing in PHP, try some of these articles:

In most cases, the drupal code is namespaced based on the module that code belongs to.

Example: namespace for block.module

namespace Drupal\block;

@todo: explain why sometimes it's Drupal\ and sometimes it's Drupal\\[Controller|Form|Plugin|etc.] and how I should know which to use ...

Read more about the Drupal namespace standards. More on PSR-4 usage in Drupal here. Correctly configured coding software should be able to pick up on PHP namespaces and provide help and autocompletions.

Dependency Injection

Although dependency injection is really just another OOP design pattern, we call it out here because Drupal 8 makes heavy use of the concept and it is important to have a baseline understanding in order to access and make use of many of the core APIs.

Read up on dependency injection on PHP the right way, as well as the additional articles linked on that page. Especially this article because Drupal makes heavy use of the Symfony service container referenced.

See also:


Symfony is a PHP framework that Drupal borrows from in order to reduce code duplication across various PHP projects. Much of the code that Drupal 8 uses to handle routing, sessions and the services container, amongst other things, is borrowed from Symfony 2 (and as Drupal 8 developed, moved into Symfony 3). If you want to know more about why this decision was made, check out this presentation by core-committer alexpott for some background.

Check out the Symfony 2 book and brush up on your Symfony knowledge. While not all of it is required to understand Drupal, knowing how Symfony works will make you both a better Drupal developer and a better PHP developer. You might also be interested in the Symfony Glossary.

Check out core/composer.json to see the symfony libraries. As of Drupal 8.4.3, these are the Symfony PHP and closely related libraries:

"php": ">=5.5.9",
"symfony/class-loader": "~3.2.8",
"symfony/console": "~3.2.8",
"symfony/dependency-injection": "~3.2.8",
"symfony/event-dispatcher": "~3.2.8",
"symfony/http-foundation": "~3.2.8",
"symfony/http-kernel": "~3.2.8",
"symfony/routing": "~3.2.8",
"symfony/serializer": "~3.2.8",
"symfony/translation": "~3.2.8",
"symfony/validator": "~3.2.8",
"symfony/process": "~3.2.8",
"symfony/polyfill-iconv": "^1.0",
"symfony/yaml": "~3.2.8",
"twig/twig": "^1.23.1",
"doctrine/common": "^2.5",
"doctrine/annotations": "^1.2",
"symfony-cmf/routing": "^1.4",
"symfony/psr-http-message-bridge": "^1.0",


Drupal 8 makes use of PHP annotations -- @docblock comments added to your code using a special syntax -- for plugin discovery and to provide additional context/meta-data for code that's being executed. Annotations are read using the Doctrine annotation parser then turned into information that Drupal can use to better understand what your code is doing.

Read more about the use of annotations for plugin discovery.

See a list of all the different annotation types in Drupal 8.

See also: PHPDoc (on Wikipedia)

@todo: link to some documentation that explains places in D8 that annotations are used, what they are used for, and how you can figure out what you can/should put into your annotations ...


Plugins provide small pieces of functionality in such a way that they can be easily swapped out for another plugin. Plugins that perform similar functionality are of the same plugin type. For example, 'Field widget' is a plugin type, and each different field widget (text field, textarea, date) is implemented with a plugin.

Read more about the Plugin API in Drupal 8.


@todo: What are these, when do you use them, etc?

Other Resources

Below is a list of additional resources to help ensure that you hit the ground running with Drupal 8.