Doctrine ORM

A mature object-relational mapper for PHP built on Doctrine DBAL

Library
Composer
v3.6.8
10,170stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
98/100Excellent
Development Activity100
Maintenance96
Community96
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture86
Code Quality85
Innovation72
Learning Curve68

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 QueryBuilder API 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

PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

754

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
47
Repo Health
66
Technical
66
Dependency
Built with
PHP63%
Vue18%
Gherkin13%
Updated 2 months ago
PHP
63%
AGPL 3.0

Hyvor Relay

Devops · AI Development · Monitoring

819

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.

View details
69
Repo Health
79
Technical
70
Dependency
Built with
PHP63%
Svelte23%
Go12%
Updated today
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

4,918

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.

View details
94
Repo Health
78
Technical
63
Dependency
Built with
PHP86%
Updated today
PHP
82%
Other

Mautic

Automation · Marketing · Ecommerce

10,366

The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.

View details
98
Repo Health
76
Technical
64
Dependency
Built with
PHP82%
Updated yesterday
PHP
99%
MIT

Shlink

Developer Tools · Marketing

5,223

Self-hosted PHP URL shortener with a full REST API, dynamic redirect rules, and real-time visit analytics under your own domain.

View details
86
Repo Health
83
Technical
72
Dependency
Built with
PHP99%
Updated 1 weeks ago
PHP
84%
MIT

wallabag

Bookmarks Archiving

12,917

Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.

View details
92
Repo Health
81
Technical
59
Dependency
Built with
PHP84%
Twig13%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search