PHP 8 introduced constructor property promotion, a feature that simplifies class property definition and assignment by letting you declare and initialize properties in the constructor signature. This tutorial demonstrates how to use constructor property promotion in Drupal custom modules (which require PHP 8.0+), specifically to simplify dependency injection in your services and controllers. We will compare the traditional Drupal pattern (used in PHP 7 and early Drupal 9) with the modern PHP 8+ approach, using full code examples for both.
Sometimes you need fixed, permanent Categories on the site, which should be updated accedentially. In this case you can utilize custom code with Event Subscribe.
Let's add a new Event Subscriber class in custom module.
drupalbook_custom.services.yml
Often we face 500 error page when Drupal, services or another sites are not available. When we see 500 (or 501-504) error page. In Drupal we use Exceptions to check some critical code was executed. If we got an error, for exaple in HTTP request to another site when Drupal will show this error "The website encountered an unexpected error. Please try again later":
This guide gives you a detailed overview of Drupal concepts, helps you understand Drupal’s structure, and assists in determining whether Drupal is the right fit for your project.
Before installing Drupal, it’s a good idea to get a general understanding of what it is and how it works—both on a local host and on any live hosting you may use. This small investment of time can greatly benefit you in the long run. Go ahead and explore Drupal best practices!
Why Drupal?
Drupal is a free open-source content management system that can be adapted and customized for both simple websites and complex web applications. Drupal grows with you, offering thousands of free modules and themes to help you reach your audience, spread your message, build brand awareness, and create a community.
The Drupal User Guide is a tutorial guide for building and maintaining Drupal websites. The User Guide is written, updated, and translated by volunteers as part of the User Guide project.
On this page, you can download electronic versions of the User Guide in English and partially/fully translated into at least 10 languages. Each language is available as a separate archive file containing versions of the User Guide in PDF, ePub, Mobi, and AZW3 formats.
This guide covers the detailed system requirements for installing Drupal.
In general, websites built using only the Drupal core (i.e., without contributed modules) are compatible with all modern browsers that support CSS and JavaScript (with minor visual differences) and are fully functional in them. Drupal only guarantees support for a list of supported browsers.
Supported Browsers
The latest release of each of the two most recent supported major versions:
Desktop browsers:
MySQL, MariaDB or Percona Server (Recommended)
MySQL 5.5.3 / MariaDB 5.5.20 / Percona Server 5.5.8 or higher is required with InnoDB as the primary storage engine, and the PDO database extension is required.
Note 1: MySQL 8 is supported only on Drupal 8.6 or later. See this issue.
Drupal 8 runs on any web server that supports the required PHP version.
Many hosting providers offer different PHP version options. The default PHP version may be older than what Drupal requires, so check your current version in your host's control panel and upgrade to the latest supported version if necessary.