Basic structure of Drupal

Last updated on
15 April 2022

This documentation needs work. See "Help improve this page" in the sidebar.

Drupal is built on the DrupalKernel and a number of ComponentsSubsystems and Core Modules. The Kernel and Components are the most core parts of Drupal. Then the base system of Drupal Subsystems and Core Modules are dependent on the Kernel and Components.

The API documentation provides an overview of many of the Drupal core APIs in a more detailed manner and are referenced in the tables below where applicable.

General Visualization of Drupal Core

Drupal Components

Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. Components MAY depend on other Drupal Components or external libraries/packages, but MUST NOT depend on any other Drupal code. In the Drupal source code tree, these components can be found under the /drupal/core/lib/Drupal/Component folder. 

The table below shows each of the 25 Components of Drupal 9.3 (which have a total of approximately 120 classes). Each Component name is linked to the code in the Drupal repository. To give a general idea of the complexity of a given Component, the Classes column shows the approximate total number of classes for each Component. In parentheses are the approximate number of Standard classes (S), Plugin derived classes (P), Exception classes (E), Final classes (F), and Abstract classes (A). The table also shows the number of Interface classes and Traits in the Component along with a link to further Drupal or Symfony documentation as applicable.

Component Classes Interfaces Traits Documentation

Annotation
13 (8S,2P,1A,2F) 1 2

Classes for annotation discovery and implementation of annotation plugins. Annotations are the appropriately formatted descriptions in the comments of classes that use certain tags such as @return, @param, and @see. The parser is based on the parser from the Doctrine project.


Assertion
2 (2S) 0 0

Provides helper functionality for runtime assertions.


Bridge
1 (1S) 0 0

Defines a bridge between the Laminas service manager to Symfony container.


ClassFinder
1 (1S) 1 0

Provides a class finding utility.


Datetime
2 (2S) 1 0

Wraps the PHP DateTime class with more flexible initialization parameters, allowing a date to be created from an existing date object, a timestamp, a string with an unknown format, a string with a known format, or an array of date parts. It also adds an errors  array and a __toString() method to the date object.


DependencyInjection
4 (4S) 0 0 Symfony DependencyInjection

Dependency Injection container optimized for Drupal's needs.


Diff
11 (11S) 0 0

Uses Diff engine based on PERL Algorithm::Diff that computes 'intelligent'' differences between two files or lists.


Discovery
3 (2S,1E) 1 0

Provides an interface for providing a type of class discovery and classes for discovery of YAML files.


EventDispatcher
2 (2S) 0 0 Symfony EventDispatcher

Provides a forward-compatibility layer for the Symfony 5 event class. Symfony 5 relies on the  Symfony\Contracts\EventDispatcher\Event class. In order to prepare for updates, code that wishes to extend Symfony's Event class should extend this intermediary class, which will handle switching from Symfony\Component to Symfony\Contracts without a further change.


FileCache
4 (4S) 2 0

Handles the caching of data based on file modification dates.


FileSecurity
1 (1S) 0 0

Provides methods for .htaccess and web.config files.


FileSystem
2 (2S) 0 0

Provides a regex file iterator and a helper for temporary directories.


FrontMatter
2 (1S,1E) 0 0

Component for parsing front matter from a source. Front matter is used as a way to provide additional static data associated with a source without affecting the contents of the source. Typically this is used in templates to denote special handling or categorization. Front matter must be the first thing in the source and must take the form of valid YAML set in between triple-hyphen lines.


Gettext
5 (5S) 4 0

PHP library for the GNU gettext project. The GNU gettext utilities are a set of tools that provides a framework within which other free packages may produce multi-lingual messages.


Graph
1 (1S) 0 0

Directed acyclic graph manipulation.


HttpFoundation
1 (1A) 0 0

Provides a common base class for safe redirects.


PhpStorage
4 (4S) 1 0

Stores and loads PHP code.


Plugin
20 (8S,7E,5A) 21 3

Base building blocks for a scalable and extensible plug-in system for PHP components and application framework extensions.


ProxyBuilder
1 (1S) 0 0

Provides a lightweight mechanism to provide lazy loaded proxies.


Render
3 (3S) 2 1

Renders placeholder variables for HTML and plain-text display.


Serialization
6 (5S,1E) 1 0

Base serialization for JSON, PHP, and YAML.


Transliteration
1 (1S) 1 0

Classes for mapping from one system of writing to another. Based loosely on the utfnormal class from the Wikimedia project.


Utility
25 (24S,1F) 2 1

Mostly static utility classes for string, xss, array, image, and other commonly needed manipulations.


Uuid
4 (4S) 1 0

UUID generation and validation.


Version
1 (1S) 0 0

Utility classes for processing Drupal specific version information.

Drupal Subsystems

Code in the Drupal\Core namespace represents Drupal Subsystems provided by the base system. These subsystems MAY depend on Drupal Components and other Subsystems, but MAY NOT depend on any code in a module. In the Drupal source code tree, these subsystems can be found under the /drupal/core/lib/Drupal/Core folder. 

The table below shows each of the 77 Subsystems of Drupal 9.3 (which have a total of approximately 1172 classes). The Subsystem name is linked to the code in the Drupal repository. To give a general idea of the complexity of a given Subsystem, the Classes column shows the approximate total number of classes for the given Subsystem. In parentheses is the approximate number of Standard classes (S), Plugin derived classes (P), Exception classes (E), Final classes (F), and Abstract classes (A). The table also shows the number of Interface classes and Traits in the Subsystem along with a link to further Drupal documentation as applicable.

Subsystem Classes Interfaces Traits Documentation

Access
14 (12S,1E,1A) 7 0

Route access control. See the Entity API section on "Access checking on entities", and the Node access API reference, and the access section of the Routing system documentation.


Action
16 (12S,4A) 1 0

Action entity plugin.


Ajax
31 (31S) 2 3 Ajax API

Ajax is the process of dynamically updating parts of a page's HTML based on data from the server. When a specified event takes place, a PHP callback is triggered, which performs server-side logic and may return updated markup or JavaScript commands to run. After the return, the browser runs the JavaScript or updates the markup on the fly, with no full page refresh necessary.


Annotation
6 (6P) 0 0 Annotations API

Building on the Annotation Component, this provides annotations for class discovery and metadata description. The Drupal plugin system has a set of reusable components that developers can use, override, and extend in their modules. Most of the plugins use annotations, which let classes register themselves as plugins and describe their metadata. (Annotations can also be used for other purposes, though at the moment, Drupal only uses them for the plugin system.)


Archiver
6 (4S,1P,1E) 1 0

Handles the tar and zip archiving tools.


Asset
21 (16S,5E) 9 0

Handles the library, CSS, and JavaScript asset collections.


Authentication
2 (2S) 4 0 Authentication Wiki

Handles authentication services using an authentication manager.


Batch
3 (3S) 1 0 Batch API

Batch functions allow forms processing to be spread out over several page requests, thus ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations. The API is primarily designed to integrate nicely with the Form API workflow, but can also be used by non-Form API scripts (like update.php) or even simple page callbacks.


Block
5 (3S,1P,1A) 5 1 Block API,
Block Wiki

Blocks in Drupal 8 are made up of two separate API structures: the Block Plugin API and the Block Entity API. The Block Plugin API is a stand-alone reusable API and the Block Entity API addresses use cases for block placement and visibility control.


Breadcrumb
2 (2S) 2 0

Handles breadcrumb building and caching.


Cache
55 (52S,3A) 11 7 Cache API,
Cache Wiki

The Cache API is used to store data that takes a long time to compute. Caching can either be permanent or valid only for a certain timespan, and the cache can contain any type of data.


CacheDecorator
0 (0) 1 0

Simple cache decorator interface.


Command
11 (11S) 0 0

Wrappers for console command component for various commands, including database dump, database import, generate proxy, install Drupal site, quick start to run a Drupal web server, and the running of a PHP web server.


Composer
1 (1S) 0 0

Provides static functions for composer script events.


Condition
4 (2S,1A,1P) 1 1

Handles what conditions are active in certain contexts.


Config
74 (43S,18E,9A,4F) 15 3 Configuration API,
Configuration Wiki

The configuration API provides a central place for modules to store configuration data. This data can be simple configuration like your site name, or more complex information managed with configuration entities, such as views and content types. Configuration is a place to store information that you would want to synchronize from development to production. This information is often created  during site-building and is not typically generated by regular users during normal site operation.


Controller
7 (3S,2A,2F) 2 0

Base classes for thin controllers, form controllers, and a title resolver interface for generating the title from a given route.


Database
68 (41S,6A,21E) 7 2 Database API,
Database Wiki

Drupal's database abstraction layer provides a unified database query API that can query different underlying databases. It is built upon PHP's PDO (PHP Data Objects) database API, and inherits much of its syntax and semantics. Besides providing a unified API for database queries, the database abstraction layer also provides a structured way to construct complex queries, and it protects the database by using good security practices.


Datetime
9 (8S,1A) 2 0

Building on the Datetime Component, this provides base classes for date list and datetime elements, date format entity, timestamp widget plugin, date formatter, and formatted date diff.


DependencyInjection
23 (21S,1A,1E) 4 2 DI API,
DI Wiki

Building on the Dependency Injection Component, this provides classes for compiler handling of dependency injection. It also has classes for dependency injection for containers, serialization, YAML files, and service providers.


Diff
1 (1S) 0 0

Building on the Diff Component, this provides a Diff Formatter class.


Discovery
1 (1S) 0 0

Based on the Discovery Component, this provides a decode method for YAML files.


Display
4 (1S,1A,2P) 3 0

Display variant plugins, interfaces, and classes to determine display of output in Drupal.


Entity
127 (94S,4P,17A,11E,1F) 62 10 Entity API,
Entity Wiki

The Entity System is the API for entities manipulation (CRUD: create, read, update, delete). Entity types in core come in two variants - Configuration Entity and Content Entity. The extensive Entity System is arguably at the core of the Drupal's unsurpassed flexibility as a CMS.


EventSubscriber
43 (41S,1A,1F) 0 0 Events API

Building on Symfony's and Drupal's EventDispathcher Component, this manages and validates subscribed events.


Executable
2 (1E,1A) 2 0

Interfaces and abstract classes for executable plugins.


Extension
29 (18S,8E,1A,2F) 6 0

Base classes for managing Drupal extensions like modules and themes. Also some helper classes like parsers for info files.


Field
77 (59S,3P,13A,2F) 17 2 Field API

Extensive base classes, interfaces, and plugins for different types of fields and for their formatting.


File
15 (7S,8E) 3 0

Building on FileSystem Component and PHP file functions, numerous helper functions to manage files.


FileTransfer
7 (4S,2A,1E) 1 0

Manage file transfer via FTP and SSH.


Flood
2 (2S) 1 0

Interface and base classes for handling flood control, e.g. too many login attempts.


Form
21 (14S,3E,4A) 11 2 Form Generation API,
Form Wiki

Form classes implement the \Drupal\Core\Form\FormInterface and the basic workflow of a form is defined by the buildForm, validateForm, and submitForm methods of the interface.


Http
23 (7S,16E,1F) 1 0

Numerous exception classes and some factory, helper, and bridge classes for managing HTTP requests.


Image
2 (2S) 1 0

Wrapper classes for handling image objects from image files.


ImageToolkit
6 (2S,2A,2P) 3 0

An image toolkit provides common image file manipulations like scaling, cropping, and rotating. Provides base classes, interfaces, and management classes.


Installer
16 (13S,3E) 0 2

Installation classes for services, route builders, module extensions, theme extensions, and a kernel installer for handling Drupal installations.


KeyValueStore
11 (10S,1A) 4 0

Interfaces, factory, memory, and database classes for key-value storage.


Language
4 (4S) 2 Language API

Interfaces and base classes for i18n multilingual support for websites.


Layout
5 (4S,1P) 3 0 Layout Wiki

Plugin, interfaces and base classes for layout of regions in a display page.


Locale
1 (1S) 1 0

Handles country codes.


Lock
4 (3S,1A) 1 0

Handles database locking.


Logger
4 (4S) 3 2 Logging Wiki

The Logging API is object oriented and PSR-3 compatible.


Mail
4 (4S) 2 0

Handles Drupal's default mail backend using PHP's native mail function.


Menu
21 (20S,1A) 14 0 Menu Wiki

The association of a path with a controller, coupled with parameter upcasting and access checking, is handled in the routing system. This system serves as a basis for path access on a Drupal site. The Drupal menu system is a collection of different APIs for menu items defined by modules as well as local tasks, actions and contextual links.


Messenger
1 (1S) 1 1

Stores runtime messages sent out to individual users on the page.


PageCache
8 (8S) 4 0

Implements policy rules for caching of page content.


Pager
3 (3S) 2 0

Interfaces and base classes for the pages when there are multiple pages to be managed.


ParamConverter
6 (5S,1E) 2 1

Responsible for converting a path parameter to the object it represents. An example is for the path: /admin/structure/block/manage/{block}. In this case, '{block}' would be the path parameter which should be turned into a block object representing the block in question. ParamConverters are defined as services tagged with 'paramconverter', and are managed by the 'paramconverter_manager' service. 


Password
2 (2S) 2 0

Secure password hashing functions for user authentication along with a password generator.


Path
7 (7S) 2 0

Validators and path matcher for URL paths.


PathProcessor
4 (4S) 2 0

Managing and decoding the inbound and outbound URL paths.


PhpStorage
1 (1S) 0 0

Factory for instantiating storage for generated PHP code.


Plugin
23 (20S,3A) 16 8 Plugin API,
Plugin Wiki

The Drupal Plugin API allows a module or subsystem to provide functionality (plugin instances) in an object-oriented way. Plugins that perform similar functionality are of the same plugin type. Module developers write plugins to extend various systems like blocks, field widgets, and image effects and add new options for administrators to choose from. 


ProxyBuilder
1 (1S) 0 0

Class to extend the
proxy builder component by using the DependencySerializationTrait.


ProxyClass
19 (19S) 0 0

Proxy classes for numerous different functionalities including batch storage, module install, database lock, bare HTML page render, and route builder.


Queue
11 (7S,3E,1A) 6 0 Queue API

Implements a queue type of data structure for Drupal that includes a queue factory and classes for garbage collection, database factory queue, queue in memory, and batches. 


Render
81 (75S,2P,2A,2F) 14 2 Render API,
Render Wiki

Drupal's Render API roughly consists of two parts: (1) the render pipeline — which is format-agnostic (HTML, JSON, anything) and (2) render arrays, which are a representation of a HTML page. They allow nesting (like HTML) and altering (necessary for Drupal's flexibility). 


RouteProcessor
2 (2S) 1 0

Based on Symfony's routing classes, this processes outbound routes for priority and other considerations.


Routing
36 (31S,2A,2E,1F) 15 2 Routing API,
Routing System Wiki

A route is a path which is defined for Drupal to return some sort of content on. For example, the default front page is a route. When Drupal receives a request, it tries to match the requested path to a route it knows about. If the route is found, then the route's  definition is used to return content. Otherwise, Drupal returns a 404. Drupal 8's routing system is heavily based on Symfony's. Drupal's routing system can do everything Symfony's can (and more), and both use the same syntax to define routes.


Security
3 (2S,1E) 1 1

Classes for sanitizing user input and concerning the trustworthiness of callbacks.


Serialization
1 (1S) 0 0 Serialization Wiki

The Serialization API is largely based on the Drupal Serialization Component, which is a wrapper for the Symofny Serializer Component. The Drupal Core Serialization module then builds on the Serialization API.


Session
12 (10S,2F) 7 0 Sesson API

Manages user session data, including permissions and securely switching between accounts.


Site
2 (1S,1F) 1 0

Handles site settings and maintenance mode.


StackMiddleware
4 (4S) 0 0 Middleware Wiki

Drupal 8 has a Middleware API that is adapted from the the StackPHP project (https://github.com/stackphp). StackPHP builds on top of Symfony's HttpKernelInterface and is a convention for composing HttpKernelInterface middleware. 


State
1 (1S) 1 0 State API,
State Wiki

The State API is simple system for the storage of information about the system's state. The information is stored in the database and will be lost when the database is dropped or the site is re-installed from configuration. For storing data which needs to be edited by humans or needs to be shared between environments use the Configuration API. 


StreamWrapper
7 (4S,3A) 3 0

Wrappers for handling file streaming for public, private, and local files.


StringTranslation
7 (7S) 2 1 Translation Wiki

When you include text in code, and the text will be displayed in the Drupal user interface, it needs to be internationalized (prepared properly) so that it can be localized (translated), so that users can make Drupal sites that are completely displayed in different languages. In Drupal, all interface text must use English as its default language. Also, the project uses automatic mechanisms to  extract translatable text strings from the code base, so that translation teams can use Drupal translations to translate the text of  Drupal Core and contributed projects. 


Template
16 (15S,1A) 0 0

Handles template files by managing twig storage, extensions, environment and policies as well as attributes in the template files. 


TempStore
7 (5S,1E,1F) 0 0

Private and shared non-cached temporary storage of data that is that available across requests. 


Test
13 (12S,1E) 1 4 Test API

Base classes, interfaces, and traits for testing the Drupal core and subsystems. 


Theme
10 (9S,1E) 3 0 Theme API

Handles Drupal themes with a registry, theme manager, theme negotiator, and theme access check. 


Transliteration
1 (1S) 0 0

Enhances PhpTransliteration component with an alter hook. 


TypedData
36 (29S,2E,1P,4A) 23 3 Typed Data API,
Typed Data Wiki

PHP is a very loosely typed language. It doesn’t have a clear definition of the different types of data it deals with. The Typed Data API provides developers a consistent way of interacting with data and also provides means of fetching metadata about the actual data. 


Update
10 (9S,1E) 0 0 Update API
Update Wiki

The Update API allows modules to provide code that will update their data models between minor versions and releases within one major version (that is, between different software/data versions all within Drupal 8+). 


Updater
5 (3S,2E) 1 0

For updating modules and themes. 


Utility
8 (7S,1E) 2 0 Utility API

Various utility classes, including for link generation, error processing, table sorting, theme registry, token and URL assembly. 


Validation
36 (35S,1P) 4 0 Entity Validation Wiki

Entity validation is a separate Entity validation API that is decoupled from form validation. Decoupling entity validation from forms allows validation entities to be independent of form submissions, such as when changed via the RESTful web service. The validation API implementation is based on the Symfony validator. 

Core modules

See separate page for a list of documentation for the approximately 76 core modules (as of Drupal 9.3x). In the Drupal source code tree, these core modules can be found under the /drupal/core/modules folder. 

Help improve this page

Page status: Needs work

You can: