---
title: "Doctrine DBAL driver middlewares"
manual: "TYPO3 Explained"
version: "12.4"
permalink: "https://docs.typo3.org/permalink/t3coreapi:database-middleware@12.4"
source: "ApiOverview/Database/Middleware/Index.rst"
rendered: "2026-10-21T15:29:37+00:00"
---

# Doctrine DBAL driver middlewares {#database-middleware}

<!-- TODO: no Markdown rendering for "versionadded" -->

Doctrine DBAL supports custom driver middlewares since version 3. 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 to implement SQL logging capabilities.

For more information on driver middlewares, see the [Architecture chapter](https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/architecture.html) of
the Doctrine DBAL documentation. Furthermore, look up the implementation of the
[EXT:adminpanel/Classes/Log/DoctrineSqlLoggingMiddleware.php (GitHub)](https://github.com/typo3/typo3/blob/12.4/typo3/sysext/adminpanel/Classes/Log/DoctrineSqlLoggingMiddleware.php) in the
Admin Panel system extension as an example.

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

In this example, the custom driver middleware `MyMiddleware` is added
to the `Default` connection:

**EXT:my_extension/ext_localconf.php | config/system/additional.php**

```php
<?php

declare(strict_types=1);

use MyVendor\MyExtension\Database\Log\MyMiddleware;

defined('TYPO3') or die();

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverMiddlewares']['myextension_mymiddleware']
    = MyMiddleware::class;

```
