Skip to content

Commit e9daeed

Browse files
committed
Add middlewares to the architecture documentation
1 parent 19792a8 commit e9daeed

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

docs/en/reference/architecture.rst

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ and a ``Doctrine\DBAL\Result`` wraps a ``Doctrine\DBAL\Driver\Result``.
1212
and ``Doctrine\DBAL\Driver\Result`` are just interfaces.
1313
These interfaces are implemented by concrete drivers.
1414

15-
What do the wrapper components add to the underlying driver
16-
implementations? The enhancements include SQL logging, events and
17-
control over the transaction isolation level in a portable manner,
18-
among others.
19-
2015
Apart from the three main components, a DBAL driver should also provide
2116
an implementation of the ``Doctrine\DBAL\Driver`` interface that
2217
has two primary purposes:
@@ -26,18 +21,40 @@ has two primary purposes:
2621
2. Act as a factory of other driver-specific components like
2722
platform, schema manager and exception converter.
2823

24+
The driver components can be decorated using the four driver interfaces in
25+
order to add driver-independent functionality like logging or profiling. Those
26+
decorators are configured as a middleware.
27+
28+
The wrapper components ``Connection``, ``Statement`` and ``Result`` are the
29+
objects that the application usually interacts with directly. They wrap the
30+
middleware stack as well as the driver at the bottom of that stack.
31+
2932
The DBAL is separated into several different packages that
3033
separate responsibilities of the different RDBMS layers.
3134

3235
Drivers
3336
-------
3437

35-
The drivers abstract a PHP specific database API by enforcing three
38+
The drivers abstract a PHP specific database API by enforcing four
3639
interfaces:
3740

38-
- ``\Doctrine\DBAL\Driver\Connection``
39-
- ``\Doctrine\DBAL\Driver\Statement``
40-
- ``\Doctrine\DBAL\Driver\Result``
41+
- ``Doctrine\DBAL\Driver``
42+
- ``Doctrine\DBAL\Driver\Connection``
43+
- ``Doctrine\DBAL\Driver\Statement``
44+
- ``Doctrine\DBAL\Driver\Result``
45+
46+
Middlewares
47+
-----------
48+
49+
A middleware sits in the middle between the wrapper components and the driver.
50+
By implementing the ``Doctrine\DBAL\Driver\Middleware``, it decorates the
51+
``Driver`` component of either the actual driver or a lower middleware. If
52+
necessary, the middleware might also decorate ``Connection``, ``Statement``
53+
and ``Result``.
54+
55+
An example for a middleware implementation is
56+
``Doctrine\DBAL\Logging\Middleware`` which implements logging capabilities
57+
on top of a driver.
4158

4259
Platforms
4360
---------
@@ -72,4 +89,3 @@ The types offer an abstraction layer for the converting and
7289
generation of types between Databases and PHP. Doctrine comes
7390
bundled with some common types but offers the ability for
7491
developers to define custom types or extend existing ones easily.
75-

0 commit comments

Comments
 (0)