# doctrine/dbal architecture

> Architecture diagram of the GitHub repository doctrine/dbal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/doctrine/dbal
- Repository: https://github.com/doctrine/dbal

## Overview

Doctrine DBAL is a PHP database abstraction layer: an application configures a connection, builds or submits SQL, and receives results through a database-specific driver. It also provides schema introspection and schema management, including portable schema models and platform-specific SQL generation. The graph highlights those two product workflows and the type-conversion layer. Some runtime files were not sampled; connections to database services and several internal handoffs are therefore omitted rather than inferred.

Main entry points: [`src/Schema/Schema.php`](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Schema.php) (Schema model), [`src/Connection.php`](https://github.com/doctrine/dbal/blob/4.5.x/src/Connection.php) (Connection), [`src/Query/QueryBuilder.php`](https://github.com/doctrine/dbal/blob/4.5.x/src/Query/QueryBuilder.php) (Query builder), [`src/DriverManager.php`](https://github.com/doctrine/dbal/blob/4.5.x/src/DriverManager.php) (Driver manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connection["Connection setup"]
  node_manager["Driver manager<br/>[DriverManager.php]"]
  node_connection_obj["Connection<br/>[Connection.php]"]
  node_middleware["Middleware<br/>[Middleware.php]"]
  node_drivers["Database drivers"]
end

subgraph group_queries["Query execution"]
  node_query_builder["Query builder<br/>[QueryBuilder.php]"]
  node_query_data["Query and parameters<br/>[Query.php]"]
  node_result["Query result<br/>[Result.php]"]
end

subgraph group_schema["Schema management"]
  node_schema_manager["Schema manager"]
  node_metadata["Metadata introspection"]
  node_schema_model["Schema model<br/>[Schema.php]"]
  node_table_model["Table and columns<br/>[Table.php]"]
  node_column_model["Column definition<br/>[Column.php]"]
  node_sequence_model["Sequence definition<br/>[Sequence.php]"]
  node_view_model["View definition<br/>[View.php]"]
  node_foreign_key["Foreign key"]
  node_name_parsing["Schema names<br/>[Parsers.php]"]
  node_schema_sql["Schema SQL builders"]
end

subgraph group_internals["Shared internals"]
  node_platform["Database platform"]
  node_types["Type conversion<br/>[Type.php]"]
end

node_application(("Application"))
node_database[("Database")]

node_application -->|"configures"| node_manager
node_manager -->|"creates"| node_connection_obj
node_manager -->|"wraps driver"| node_middleware
node_connection_obj -->|"creates builder"| node_query_builder
node_query_builder -.->|"builds query"| node_query_data
node_query_builder -->|"executes query"| node_connection_obj
node_connection_obj -.->|"dispatches"| node_drivers
node_drivers -.->|"sends SQL"| node_database
node_connection_obj -.->|"returns result"| node_result
node_query_builder -->|"gets platform"| node_platform
node_column_model -->|"resolves type"| node_types
node_schema_manager -->|"creates provider"| node_metadata
node_schema_manager -->|"requests metadata"| node_platform
node_metadata -.->|"provides schema"| node_schema_model
node_schema_model -->|"builds create SQL"| node_schema_sql
node_schema_model -->|"holds tables"| node_table_model
node_table_model -.->|"holds columns"| node_column_model
node_schema_model -->|"holds sequences"| node_sequence_model
node_schema_model -.->|"holds views"| node_view_model
node_schema_model -.->|"models constraints"| node_foreign_key
node_schema_model -->|"parses names"| node_name_parsing
node_schema_sql -.->|"generates SQL"| node_platform

click node_manager "https://github.com/doctrine/dbal/blob/4.5.x/src/DriverManager.php"
click node_connection_obj "https://github.com/doctrine/dbal/blob/4.5.x/src/Connection.php"
click node_middleware "https://github.com/doctrine/dbal/blob/4.5.x/src/Driver/Middleware.php"
click node_drivers "https://github.com/doctrine/dbal/tree/4.5.x/src/Driver"
click node_query_builder "https://github.com/doctrine/dbal/blob/4.5.x/src/Query/QueryBuilder.php"
click node_query_data "https://github.com/doctrine/dbal/blob/4.5.x/src/Query.php"
click node_result "https://github.com/doctrine/dbal/blob/4.5.x/src/Result.php"
click node_platform "https://github.com/doctrine/dbal/blob/4.5.x/src/Platforms/AbstractPlatform.php"
click node_types "https://github.com/doctrine/dbal/blob/4.5.x/src/Types/Type.php"
click node_schema_manager "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/AbstractSchemaManager.php"
click node_metadata "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Introspection/IntrospectingSchemaProvider.php"
click node_schema_model "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Schema.php"
click node_table_model "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Table.php"
click node_column_model "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Column.php"
click node_sequence_model "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Sequence.php"
click node_view_model "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/View.php"
click node_foreign_key "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/ForeignKeyConstraint.php"
click node_name_parsing "https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Name/Parsers.php"
click node_schema_sql "https://github.com/doctrine/dbal/blob/4.5.x/src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manager,node_connection_obj,node_middleware,node_drivers toneBlue
class node_query_builder,node_query_data,node_result,node_database toneAmber
class node_schema_manager,node_metadata,node_schema_model,node_table_model,node_column_model,node_sequence_model,node_view_model,node_foreign_key,node_name_parsing,node_schema_sql toneMint
class node_platform,node_types toneRose
class node_application toneIndigo
```

## Components

### Connection setup

- [Driver manager](https://github.com/doctrine/dbal/blob/4.5.x/src/DriverManager.php): `src/DriverManager.php`
- [Connection](https://github.com/doctrine/dbal/blob/4.5.x/src/Connection.php): `src/Connection.php`
- [Middleware](https://github.com/doctrine/dbal/blob/4.5.x/src/Driver/Middleware.php): `src/Driver/Middleware.php`
- [Database drivers](https://github.com/doctrine/dbal/tree/4.5.x/src/Driver): `src/Driver`

### Query execution

- [Query builder](https://github.com/doctrine/dbal/blob/4.5.x/src/Query/QueryBuilder.php): `src/Query/QueryBuilder.php`
- [Query and parameters](https://github.com/doctrine/dbal/blob/4.5.x/src/Query.php): `src/Query.php`
- [Query result](https://github.com/doctrine/dbal/blob/4.5.x/src/Result.php): `src/Result.php`

### Schema management

- [Schema manager](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/AbstractSchemaManager.php): `src/Schema/AbstractSchemaManager.php`
- [Metadata introspection](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Introspection/IntrospectingSchemaProvider.php): `src/Schema/Introspection/IntrospectingSchemaProvider.php`
- [Schema model](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Schema.php): `src/Schema/Schema.php`
- [Table and columns](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Table.php): `src/Schema/Table.php`
- [Column definition](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Column.php): `src/Schema/Column.php`
- [Sequence definition](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Sequence.php): `src/Schema/Sequence.php`
- [View definition](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/View.php): `src/Schema/View.php`
- [Foreign key](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/ForeignKeyConstraint.php): `src/Schema/ForeignKeyConstraint.php`
- [Schema names](https://github.com/doctrine/dbal/blob/4.5.x/src/Schema/Name/Parsers.php): `src/Schema/Name/Parsers.php`
- [Schema SQL builders](https://github.com/doctrine/dbal/blob/4.5.x/src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php): `src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php`

### Shared internals

- [Database platform](https://github.com/doctrine/dbal/blob/4.5.x/src/Platforms/AbstractPlatform.php): `src/Platforms/AbstractPlatform.php`
- [Type conversion](https://github.com/doctrine/dbal/blob/4.5.x/src/Types/Type.php): `src/Types/Type.php`

### Other components

- **Application**
- **Database**

## Connections

- Application → Driver manager: configures (evidence: `src/DriverManager.php`)
- Driver manager → Connection: creates (evidence: `src/DriverManager.php`)
- Driver manager → Middleware: wraps driver (evidence: `src/DriverManager.php`)
- Connection → Query builder: creates builder (evidence: `src/Query/QueryBuilder.php`)
- Query builder → Query and parameters: builds query (evidence: `src/Query/QueryBuilder.php`)
- Query builder → Connection: executes query (evidence: `src/Query/QueryBuilder.php`)
- Connection → Database drivers: dispatches
- Database drivers → Database: sends SQL
- Connection → Query result: returns result
- Query builder → Database platform: gets platform (evidence: `src/Query/QueryBuilder.php`)
- Column definition → Type conversion: resolves type (evidence: `src/Schema/Column.php`)
- Schema manager → Metadata introspection: creates provider (evidence: `src/Schema/AbstractSchemaManager.php`)
- Schema manager → Database platform: requests metadata (evidence: `src/Schema/AbstractSchemaManager.php`)
- Metadata introspection → Schema model: provides schema
- Schema model → Schema SQL builders: builds create SQL (evidence: `src/Schema/Schema.php`)
- Schema model → Table and columns: holds tables (evidence: `src/Schema/Schema.php`)
- Table and columns → Column definition: holds columns
- Schema model → Sequence definition: holds sequences (evidence: `src/Schema/Schema.php`)
- Schema model → View definition: holds views (evidence: `src/Schema/View.php`)
- Schema model → Foreign key: models constraints (evidence: `src/Schema/ForeignKeyConstraint.php`)
- Schema model → Schema names: parses names (evidence: `src/Schema/Schema.php`)
- Schema SQL builders → Database platform: generates SQL
