---
title: "Feature: #102496 - Introduce global Doctrine DBAL driver middlewares"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-102496-1700775381"
source: "Changelog/13.0/Feature-102496-IntroduceGlobalDoctrineDBALDriverMiddlewares.rst"
typo3-version: "13.0"
typo3-major: 13
type: "feature"
issue: 102496
forge: "https://forge.typo3.org/issues/102496"
tags: ["Database", "PHP-API", "ext:core"]
rendered: "2026-09-20T18:31:11+00:00"
---

# Feature: #102496 - Introduce global Doctrine DBAL driver middlewares {#feature-102496-1700775381}

See [forge#102496](https://forge.typo3.org/issues/102496)

## Description {#description}

Since v3, Doctrine DBAL supports adding custom driver middlewares. These
middlewares act as a decorator around the actual `Driver` component.
Subsequently, the `Connection`, `Statement` and `Result` components can be
decorated as well. These middlewares must implement the
`\Doctrine\DBAL\Driver\Middleware` interface.
A common use case would be a middleware for implementing SQL logging capabilities.

For more information on driver middlewares,
see [https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/architecture.html](https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/architecture.html).
Furthermore, you can look up the implementation of the
`\TYPO3\CMS\Adminpanel\Log\DoctrineSqlLoggingMiddleware` in ext:adminpanel
as an example.

With [Feature: #100089 - Introduce Doctrine DBAL v3 driver middlewares](https://docs.typo3.org/permalink/changelog:feature-100089-1677961107) this
has been introduced as a configuration per connection.

Now it's also possible to register global driver middlewares once, which are applied
to all configured connections and then the specific connection middlewares.

See [sortable Doctrine DBAL middleware registration](https://docs.typo3.org/permalink/changelog:feature-102586-1701536342) feature
changelog for further details about the middleware configuration block.

> [!WARNING]
> Do not remove or disable provided global Core driver middlewares which are
> essential.

## Registering a new global driver middleware {#registering-a-new-global-driver-middleware}

```php
use MyVendor\MyExt\Doctrine\Driver\CustomGlobalDriverMiddleware;

// Register a global middleware
$GLOBALS['TYPO3_CONF_VARS']['DB']['globalDriverMiddlewares']['my-ext/custom-global-driver-middleware'] = [
  'target' => CustomGlobalDriverMiddleware::class,
  'after' [
    // NOTE: Custom driver middleware should be registered after essential
    //       TYPO3 Core driver middlewares. Use the following identifiers
    //       to ensure that.
    'typo3/core/custom-platform-driver-middleware',
    'typo3/core/custom-pdo-driver-result-middleware',
  ],
];
```

## Disable a global middleware for a specific connection {#disable-a-global-middleware-for-a-specific-connection}

```php
use MyVendor\MyExt\Doctrine\Driver\CustomGlobalDriverMiddleware;

// Register a global middleware
$GLOBALS['TYPO3_CONF_VARS']['DB']['globalDriverMiddlewares']['my-ext/custom-global-driver-middleware'] = [
  'target' => CustomGlobalDriverMiddleware::class,
  'after' [
    // NOTE: Custom driver middleware should be registered after essential
    //       TYPO3 Core driver middlewares. Use the following identifiers
    //       to ensure that.
    'typo3/core/custom-platform-driver-middleware',
    'typo3/core/custom-pdo-driver-result-middleware',
  ],
];

// Disable a global driver middleware for a specific connection
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['SecondDatabase']['driverMiddlewares']['my-ext/custom-global-driver-middleware']['disabled'] = true;
```

## Impact {#impact}

Using custom global middlewares allows to enhance the functionality of Doctrine
components for all connections.
