$ show doctrine/DoctrineBundle
DoctrineBundle is a Symfony bundle that integrates Doctrine DBAL and ORM into Symfony applications. It provides dependency injection configuration (YAML/XML/PHP), autowiring of connections and entity managers, console commands for schema management, a web profiler data collector, and middleware support. The bundle uses compiler passes and PHP 8 attributes to automatically register custom types, entity listeners, middlewares, and repository services. It is a mature, well-tested integration layer that bridges Symfony's container with Doctrine's persistence layer, enabling standard CRUD and advanced ORM workflows. The architecture follows Symfony bundle conventions with clean separation of concerns (DependencyInjection, Mapping, Middleware, Repository, Command).
The LLM identified 4 files worth highlighting for reuse:
A configurable schema asset filter that applies a list of regex patterns to include/exclude tables, sequences, and other schema assets. It implements Doctrine DBAL's FilterSchemaAssetsExpressionInterface and can be reused across projects to restrict schema tooling (e.g., migrations, diff) to a subset of database objects. Demonstrates clear regex filtering logic with negative lookahead support.
A DBAL middleware that closes idle database connections after a configurable TTL. It tracks the last query time and pings the connection, only disconnecting if idle. Reusable in any Symfony project using Doctrine DBAL to reduce server resource usage. Designed with ConnectionNameAwareInterface for per-connection naming.
A base repository class that extends Doctrine ORM EntityRepository but allows constructor injection of the EntityManager via autowiring. Simplifies creating custom repository services that can be registered as Symfony services. The pattern is widely used and easily extractable to other frameworks via the same constructor signature.
A data holder that captures debug backtraces for executed SQL queries. It stores query execution summaries and provides methods to collect and reset trace data. Useful for any project that needs to correlate SQL queries with their PHP call sites for profiling or logging. Implements a simple in-memory store pattern.