From ef8a55c5c91a3878d3973be3dccd9fbfc0aa60ff Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Wed, 3 May 2023 22:46:52 +0200 Subject: [PATCH] Add documentation to integrate middlewares --- Resources/doc/index.rst | 1 + Resources/doc/middlewares.rst | 90 +++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Resources/doc/middlewares.rst diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index f4bc0c18d..a96897086 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -10,4 +10,5 @@ configuration options, console commands and even a web debug toolbar collector. entity-listeners event-listeners custom-id-generators + middlewares configuration diff --git a/Resources/doc/middlewares.rst b/Resources/doc/middlewares.rst new file mode 100644 index 000000000..1b6138c5e --- /dev/null +++ b/Resources/doc/middlewares.rst @@ -0,0 +1,90 @@ +Middlewares +=========== + +Doctrine DBAL supports middlewares. According to the `Doctrine documentation`_: + + "A middleware sits in the middle between the wrapper components and the driver" + +They allows to decorates the following DBAL classes: + +- Doctrine\\DBAL\\Driver +- Doctrine\\DBAL\\Driver\\Connection +- Doctrine\\DBAL\\Driver\\Statement +- Doctrine\\DBAL\\Driver\\Result + +Symfony, for instance, uses a middleware to harvest the queries executed by the current page and make them available in the profiler. + +.. _`Doctrine documentation`: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/architecture.html#middlewares + +You can also create your own middleware. This is an example of a (very) simple middleware that prevent database connection with the root user. +The first step is to create the middleware: + +.. code-block:: php + +