Doctrine ORM

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

Library
Composer
v3.7.2
10,165 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
97 /100 Excellent
Development Activity 96
Maintenance 96
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 86
Code Quality 85
Innovation 72
Learning Curve 68

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

761

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

View details
76
Repo Health
66
Technical
65
Dependency
Built with
PHP 63%
Vue 18%
Gherkin 13%
Updated 2 weeks ago
PHP
63%
AGPL 3.0

Hyvor Relay

AI Development · Devops · Monitoring

908

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
68
Repo Health
79
Technical
70
Dependency
Built with
PHP 63%
Svelte 23%
Go 11%
Updated 1 weeks ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

5,046

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
64
Dependency
Built with
PHP 86%
Updated 4 days ago
PHP
82%
Other

Mautic

Automation · Ecommerce · Marketing

10,570

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

View details
97
Repo Health
76
Technical
63
Dependency
Built with
PHP 82%
Updated 1 weeks ago
PHP
99%
MIT

Shlink

Developer Tools · Marketing

5,307

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

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

wallabag

Bookmarks Archiving

12,989

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
93
Repo Health
81
Technical
59
Dependency
Built with
PHP 84%
Twig 13%
Updated 4 days ago

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