22.06.2026 | Mathias Grab

How to enable Twig debug in Drupal

development.services.yml
parameters:
  twig.config:
    debug: true
    auto_reload: null
    cache: false

Issue:

You work with Twig templates and need to use the debugger.

Solution:

Code solution:
Enable Twig debug by copying the snippet provided from root/web/sites/default.services.yml into root/web/sites/development.services.yml

See also: Drupal Docs on Twig

Sitebuilding solution:
Navigate to the administrative area via the admin toolbar to Configuration -> Development -> Development settings or via the path /admin/config/development/settings
 

Enabling twig debug 1


Enable the checkbox Twig development mode, as well as Twig debug mode and Disable Twig cache.
 

Enabling twig debug 3

 

For further information regarding Drupal and Twig take a look at  https://www.drupal.org/docs/develop/theming-drupal/twig-in-drupal/debugging-twig-templates

Info

This should only be used for local development environments but disabled in production.

Weitere DevBits

13.11.2025 | Peter Majmesku

Autowire services with the Autowire attribute in Drupal

Example.php
<?php

declare(strict_types=1);

namespace Drupal\my_module;

use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class Example {

  public function __construct(
    #[Autowire(service: 'current_user')]
    private readonly AccountInterface $currentUser,
  ) {
  }

  public function getCurrentUser(): AccountInterface {
    return $this->currentUser;
  }

}

my_module.services.yml
services:
  my_module.example:
    class: Drupal\my_module\Service\Example
    autowire: true
  Drupal\my_module\Service\Example: '@my_module.example'

php
services
yml / yaml
02.04.2026 | Michael Ebert

Set a custom theme to be used by Symfony Mailer

symfony_mailer.mailer_policy._.yml
configuration:
  email_theme:
    theme: my_custom_theme

yml / yaml
symfony
mail
themes