Skip to content
CAI
Software that uses CAICheck a score

doctrine/DoctrineBundle

52.8

Adequate · 19 September 2026

4.9k

lines of production code

PHP

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the DoctrineBundle for Symfony, serving as the integration layer that configures and manages Doctrine ORM and DBAL within the framework. It provides core infrastructure for database connectivity, entity management, and query execution, while offering developer tools for debugging, profiling, and SQL formatting. The bundle facilitates service wiring through modern PHP attributes and compiler passes, and supports custom extensions for types, listeners, and ID generators.

How it got here

2010 — DoctrineBundle 4.0 cleanup and restructuring

8 changes.

The codebase underwent a major restructuring to prepare for the DoctrineBundle 4.0 release, involving the removal of numerous legacy console commands, controllers, and configuration schemas. This period focused on eliminating deprecated code paths and modernizing the internal architecture, such as replacing the old dependency injection extension and data collector. Comprehensive test coverage was added to verify the new structure and ensure the stability of the remaining components.

2011–2025 — Doctrine Bundle v7 modernization

15 changes.

This period focused on upgrading the Doctrine Bundle to support Doctrine ORM 3.x, DBAL 4, and PHP 8.4, involving a complete rewrite of the configuration system to drop YAML and XML mappings in favor of PHP attributes. The work introduced new PHP attributes for autoconfiguring services, modernized internal components like cache warmers and commands, and added features such as native lazy object support and enhanced debugging middleware. Additionally, the profiler and data collectors were enhanced to provide deeper insights into query performance and cache statistics.

Features

Custom ID generator support and entity listener service resolution

The mapping layer now supports custom ID generators and resolves entity listeners via the service container. A new MappingDriver wraps the existing driver to inject custom ID generator instances from a service locator into metadata, enabling the use of custom generators defined as services. Additionally, a new ClassMetadataFactory handles the final setup of custom ID generators after metadata loading, and a ContainerEntityListenerResolver implements a new EntityListenerServiceResolver interface to resolve entity listeners from the service container rather than instantiating them directly.

src/Mapping · high confidence

Enhanced Doctrine data collection with entity validation and cache statistics

The DoctrineDataCollector now collects detailed entity metadata (class names, file paths, line numbers) and validates entity schemas during request collection, exposing validation errors in the debug toolbar. It also aggregates second-level cache statistics, including hit/miss/put counts and per-region metrics, providing deeper insight into cache performance and entity state management.

src/DataCollector · high confidence

New Doctrine database profiler templates with query grouping and cache metrics

The profiler now includes dedicated templates for the Doctrine database collector, introducing a modern UI that displays query counts, execution times, and invalid entity warnings in the toolbar. The main panel provides detailed metrics including managed entities and second-level cache statistics (hits, misses, puts) when enabled. A key behavioral change is that large numbers of queries are grouped by default (triggered when query count exceeds 100), with an option to view all individual queries, improving performance and readability for applications with high database activity.

templates · high confidence

New PHP attributes for autoconfiguring Doctrine services

The bundle now provides four new PHP attributes in the \Doctrine\\Bundle\\DoctrineBundle\\Attribute\ namespace to simplify service configuration: \AsDbalType\ for registering custom DBAL types, \AsDoctrineListener\ for autoconfiguring DBAL event listeners, \AsEntityListener\ for autoconfiguring ORM entity listeners, and \AsMiddleware\ for registering DBAL middlewares. These attributes allow developers to annotate their classes directly, reducing the need for manual XML or YAML service tag definitions.

src · high confidence

New Twig extension for SQL query formatting and parameter replacement

A new \DoctrineExtension\ class has been added to the \src/Twig\ directory, introducing three new Twig filters: \doctrine\_prettify\_sql\, \doctrine\_format\_sql\, and \doctrine\_replace\_query\_parameters\. The \doctrine\_replace\_query\_parameters\ filter allows users to replace placeholders in SQL queries with escaped values, supporting both sequential numeric keys and named parameters, while the formatting filters provide SQL syntax highlighting and prettification using Doctrine's SQL formatter.

src/Twig · high confidence

New middleware components for connection management and enhanced debugging

The middleware layer now includes \IdleConnectionMiddleware\ to manage connection lifecycles based on TTLs, \BacktraceDebugDataHolder\ to capture and expose call stacks alongside query data for deeper debugging insights, and \DebugMiddleware\ to integrate these capabilities with the Symfony Stopwatch and connection registry. A new \ConnectionNameAwareInterface\ allows these components to correctly identify and handle specific database connections.

src/Middleware · high confidence

Removals

Removal of DoctrineController class

The DoctrineController class, previously located in the DoctrineBundle, has been removed. This eliminates the built-in controller that provided methods for accessing database connections, entity managers, and creating DQL queries directly from the controller context.

Controller · high confidence

Removal of legacy Doctrine XML schema definition

The legacy \doctrine-1.0.xsd\ schema file has been removed from the configuration resources. This file previously defined the XML structure for DBAL connections and ORM entity managers using a flat, attribute-based format. Its removal indicates that the bundle no longer supports this specific version of the XML configuration schema, requiring users to migrate to the current configuration format.

Resources/config/schema · high confidence

Removal of legacy DoctrineDataCollector

The legacy DoctrineDataCollector class has been removed from the codebase. This component previously collected basic database query statistics (such as query count and SQL text) by accessing the container's DBAL logger service and displaying them in the profiler. Its removal indicates a shift away from this specific data collection mechanism, likely in favor of more modern profiling middleware or integration points within the Symfony ecosystem.

DataCollector · high confidence

Removal of legacy DoctrineExtension class

The legacy DoctrineExtension class, which previously handled the loading of DBAL and ORM configurations via XML files and manual service definition, has been removed. This change eliminates the old configuration loading mechanism in favor of the bundle's modernized dependency injection extension, simplifying the internal structure and removing deprecated code paths.

DependencyInjection · high confidence

Removed DbalLogger from DoctrineBundle

The DbalLogger class, previously located in the DoctrineBundle namespace, has been removed. This class extended DebugStack to log SQL queries and parameters via a provided LoggerInterface, using var\_export for parameter formatting. Its removal indicates that this specific logging implementation is no longer part of the framework's standard distribution.

Logger · high confidence

Removed deprecated Doctrine console commands

The DoctrineBundle has removed a large set of legacy console commands, including \doctrine:cache:clear-metadata\, \doctrine:cache:clear-query\, \doctrine:cache:clear-result\, \doctrine:database:create\, \doctrine:database:drop\, \doctrine:schema:create\, \doctrine:schema:drop\, \doctrine:ensure-production-settings\, \doctrine:generate:entities\, \doctrine:generate:entity\, \doctrine:generate:proxies\, \doctrine:generate:repositories\, \doctrine:mapping:convert\, \doctrine:mapping:import\, \doctrine:mapping:convert-d1-schema\, and \doctrine:data:load\. These commands are no longer available in the application, requiring users to migrate to alternative tools or external bundles for these database and entity management tasks.

Command · high confidence

Behavioural changes

Cache warmer is now internal and uses modern PHP features

The DoctrineMetadataCacheWarmer class has been marked as internal (@internal) and is no longer intended for direct use by application code. It now extends AbstractPhpFileCacheWarmer, utilizes strict types, and employs constructor property promotion for cleaner instantiation. The warmer checks if the cache file already exists before proceeding and ensures metadata is loaded before warming.

src/CacheWarmer · high confidence

Configuration system rewritten for Doctrine Bundle v7

The bundle's configuration and extension logic have been completely rewritten to support Doctrine ORM 3.x and DBAL 4, dropping support for YAML and XML mapping formats in favor of PHP attributes. The new \Configuration.php\ and \DoctrineExtension.php\ files implement a modernized configuration tree that enforces strict typing, removes deprecated options (such as \use\_savepoints\ and \collate\ defaults), and introduces new features like native lazy object support and idle connection listeners. Users must migrate their configuration to the new structure and ensure they are using PHP 8.4+.

src/DependencyInjection · high confidence

Doctrine configuration migrated to PHP-based service definitions

The bundle's configuration files have been converted from XML to PHP, introducing new service definition files for DBAL, ORM, Messenger, and middlewares. This change modernizes the internal wiring of Doctrine services, including the registration of console commands, data collectors, and middleware, while maintaining the same external API for users.

config · high confidence

New compiler passes for schema, middleware, and listener wiring

The bundle introduces several new compiler passes in the DependencyInjection/Compiler directory to handle internal wiring of Doctrine components. CacheSchemaSubscriberPass injects Doctrine DBAL cache adapter references into the schema listener, while DbalSchemaFilterPass processes doctrine.dbal.schema\_filter tags to configure schema asset filters per connection. EntityListenerPass registers entity listeners with priority sorting and lazy-loading support, and IdGeneratorPass registers custom ID generators via a service locator. MiddlewaresPass sorts and assigns connection-specific middleware references, and RegisterDbalTypePass auto-registers DBAL types using the new AsDbalType attribute with Symfony 7.3 compatibility. Finally, RemoveLoggingMiddlewarePass and RemoveProfilerControllerPass conditionally remove unused profiler/logging services, and ServiceRepositoryCompilerPass wires repository services into the container factory.

src/DependencyInjection/Compiler · high confidence

Refactored database management commands with new base class

The database management commands (\doctrine:database:create\, \doctrine:database:drop\) have been refactored to extend a new internal \DoctrineCommand\ base class, which simplifies dependency injection by accepting the \ManagerRegistry\ directly in the constructor. This change improves code structure and type safety while preserving existing command behaviors, including support for the \--connection\ option and specific handling for PostgreSQL and SQLite platforms.

src/Command · high confidence

Repository structure and metadata reorganized for DoctrineBundle 4.0

The repository has been restructured to support the upcoming DoctrineBundle 4.0 release. This includes adding metadata files (\.doctrine-project.json\, \.symfony.bundle.yaml\) to define version branches and maintenance status, updating \.gitattributes\ and \.gitignore\ to manage exports and local artifacts, and introducing static analysis configurations (PHPStan level 8, PHPCS). Documentation has been updated to point to symfony.com, and legacy upgrade guides (2.10–3.2) have been added to document breaking changes such as the removal of ORM 2 support, YML/annotation drivers, and various deprecated configuration options.

(repo-wide) · high confidence

Simplified repository base class and container-aware factory

Users can now extend the new ServiceEntityRepository base class, which accepts a ManagerRegistry and entity class name in its constructor, enabling simpler autowiring of custom repositories. Additionally, the ContainerRepositoryFactory has been introduced to fetch custom repositories directly from the service container when available, falling back to standard instantiation if the service is not registered, thereby improving integration with dependency injection.

src/Repository · high confidence

Updated Doctrine configuration schema to version 1.0

The XML configuration schema for Doctrine has been updated to version 1.0, introducing support for native PHP lazy objects via the new \enable-native-lazy-objects\ attribute on the ORM configuration. The schema also adds support for configuring identity generation preferences and the \fetch\_mode\_subselect\_batch\_size\ setting, while removing deprecated configuration nodes such as \disable\_type\_comments\, \use\_savepoints\, \report\_fields\_where\_declared\, and \override-url\.

config/schema · high confidence

Test coverage

Added functional and unit tests for DoctrineBundle components; Added test fixtures for NewXmlBundle.

Dependencies

Doctrine Bundle 2.15 updates dependencies for PHP 8.4, Symfony 8, and Doctrine ORM 3/DBAL 4

The \composer.json\ manifest has been updated to require PHP 8.4 and align with major ecosystem shifts: it now requires Doctrine DBAL ^4.0 and Doctrine ORM ^3.4.4 (with a conflict preventing ORM \<3.0 or \>=4.0), and supports Symfony 6.4, 7.0, and 8.0 components. Development dependencies have also been upgraded to PHPUnit ^12.3.10, PHPStan ^2.1.13, and doctrine/coding-standard ^14, while dropping older version constraints for Twig and other libraries.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 53.

Lenses

  • Code Health 91
  • Architecture 84
  • Maturity 37
  • Readiness 73
  • Security 74
  • Accessibility 56

Changes since last survey

  • 300 commits — 271 feature/other, 29 fixes

By area

  • (repo) — 130 commits
  • (root) — 40 commits
  • .github/workflows — 40 commits
  • src/DependencyInjection — 26 commits
  • tests/DependencyInjection — 19 commits
  • docs/en — 6 commits
  • src/Command — 5 commits
  • src/Twig — 4 commits
  • tests/Command — 3 commits
  • .github/dependabot.yml — 2 commits
  • config/messenger.php — 2 commits
  • config/orm.php — 2 commits
  • src/CacheWarmer — 2 commits
  • src/ConnectionFactory.php — 2 commits
  • src/DoctrineBundle.php — 2 commits
  • src/Registry.php — 2 commits
  • src/Repository — 2 commits
  • templates/Collector — 2 commits
  • tests/Middleware — 2 commits
  • tests/RegistryTest.php — 2 commits

Notable commits

  • fix: Add functional regression test for EntityValueResolver on primary-key routes (#2230)
  • fix: Fix BC break in DoctrineOrmMappingsPass
  • fix: Fix BC break in DoctrineOrmMappingsPass (#2191)
  • fix: Fix PHPUnit warning on incomplete version constraint (#2266)
  • fix: Fix attribute driver mapping pass compatibility with ORM 3 (#2120)
  • fix: Fix coding standard: use aliased class name in RequiresMethod attribute
  • fix: Fix dark theme time bar colors in the profiler
  • fix: Fix detectMappingType if the entity contain a package attribute
  • fix: Fix doctrine:database:create failing without server_version for some connections
  • fix: Fix doctrine:database:create failing without server_version for some connections
  • fix: Fix escaped placeholder and interpolate paramters with non sequential numeric keys (#2073)
  • fix: Fix logger service priority alignment with FrameworkBundle (#2275)
  • fix: Fix regex to match php allowed char in namespace
  • fix: Fix region_lifetime not applied to explicitly declared SLC regions
  • fix: Merge pull request #2047 from greg0ire/fix-attributes
  • fix: Merge pull request #2093 from greg0ire/revert-breaking-change
  • fix: Merge pull request #2115 from jtattevin/fix-2111-detect-mapping-type-with-package
  • fix: Merge pull request #2125 from greg0ire/fix-build
  • fix: Merge pull request #2187 from alcohol/fix-2186
  • fix: Merge pull request #2207 from nicolas-grekas/fix-wiring
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

doctrine/DoctrineBundle was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit e6cd6aca912a5701fdc9bf4f0ad8f18f3f1448ed — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.