Doctrine ORM
A mature object-relational mapper for PHP built on Doctrine DBAL
Repository Health
Technical Analysis
Doctrine ORM is a well-established object-relational mapper for PHP that maps plain PHP objects to relational database tables using attribute, annotation, XML, or PHP-based mapping metadata. It layers a rich entity-persistence model — including a unit-of-work pattern for tracking object changes and a database-agnostic query language (DQL) — on top of the lower-level Doctrine DBAL abstraction layer.
Used as the default ORM in Symfony applications and widely adopted across the broader PHP ecosystem, Doctrine ORM provides lazy loading, identity-map-based entity management, second-level caching, and a query builder that compiles DQL down to native SQL for the configured database platform.
What You Get
- Entity mapping via PHP attributes, annotations, XML, or programmatic configuration
- A unit-of-work pattern that automatically tracks and persists changes to managed entities
- DQL (Doctrine Query Language), an object-oriented query language compiled to native SQL per database platform
- A fluent
QueryBuilderAPI as an alternative to writing raw DQL strings - Lazy-loading proxies and configurable second-level caching for relations and query results
- Schema generation and migration tooling via the Doctrine Tools/CLI ecosystem
Common Use Cases
- Mapping domain entities to relational tables in Symfony and other PHP framework applications
- Writing database-portable queries via DQL instead of hand-written, database-specific SQL
- Managing complex object graphs with automatic change tracking through the unit-of-work pattern
- Building admin/CRUD interfaces and APIs backed by a normalized relational schema
Under The Hood
Architecture - The library is organized around EntityManager as the central façade, which coordinates a UnitOfWork (tracking entity state and computing changesets), Persisters/ (translating entity operations into SQL against Doctrine DBAL), Mapping/ (reading attribute/annotation/XML metadata into ClassMetadata), and Query/QueryBuilder (parsing and compiling DQL into SQL). PersistentCollection and the Proxy namespace implement lazy-loading for to-many and to-one associations respectively, deferring database hits until the data is actually accessed.
Tech Stack - Doctrine ORM requires PHP 8.1+ and depends on sibling Doctrine packages — doctrine/dbal for the underlying database abstraction, doctrine/collections for typed collection wrappers, and doctrine/event-manager/doctrine/deprecations for its event system and deprecation tracking — reflecting the broader Doctrine project’s modular, multi-package architecture.
Code Quality - The project maintains parallel support branches (4.0.x, 3.7.x, 3.6.x, 2.21.x, 2.20.x) each with its own CI build status and coverage badge, indicating disciplined backport/maintenance practices across major versions. With roughly 450 source files under src/, responsibilities are cleanly separated by namespace (Cache, Mapping, Persisters, Query, Repository), and the project carries an active hacktoberfest topic reflecting a large external contributor base alongside its GitHub coverage tracking.
API Design - The EntityManager/Repository pattern gives a familiar, framework-agnostic entry point ($em->persist(), $em->flush(), $repository->find()) that many PHP developers already know from Symfony. DQL intentionally mirrors SQL syntax closely, which shortens the learning curve for anyone with SQL experience, though newcomers still need to understand unit-of-work semantics (identity map, deferred flush) to avoid surprises around when writes actually hit the database.
Used by 6 apps in this directory
BillaBear
Ecommerce · Invoicing Finance
Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.
Hyvor Relay
Devops · AI Development · Monitoring
Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.
Shlink
Developer Tools · Marketing
Self-hosted PHP URL shortener with a full REST API, dynamic redirect rules, and real-time visit analytics under your own domain.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.