Skip to content

Doctrine ORM

A PHP library that maps PHP objects to database tables so you can save and load them without writing SQL by hadoctrine/orm

Stars
10.2k
Forks
2.5k
Licence
MIT
Language
PHP
Last update
5 days ago
Type
Library

What it is

Doctrine ORM is an object-relational mapper for PHP 8.1 and newer. It lets developers store and retrieve PHP objects in a database, and it sits on top of a database abstraction layer (DBAL). It also offers Doctrine Query Language (DQL), an object-oriented query language inspired by Hibernate's HQL, as an alternative to writing raw SQL.

  • Map PHP classes to database tables and persist them with transparent saving and loading
  • Write queries in DQL against your objects instead of raw SQL strings
  • Build a data layer for a PHP web application on top of the Doctrine DBAL

Great for

  • PHP developers building applications that store structured data in a relational database
  • Teams that want database queries expressed in terms of their own objects
  • Developers familiar with ORMs such as Hibernate who are working in PHP
  • Projects in the Doctrine ecosystem that already use its DBAL

Not ideal for

  • People who only need simple SQL scripts or a non-PHP stack, since the README describes it as a PHP library
  • Projects on PHP versions below 8.1, which the README lists as the minimum requirement
  • Non-developers looking for a finished end-user application
Step-by-step guide: how to use Doctrine ORMInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: PHP 8.1+

    Clone the repository

    git clone https://github.com/doctrine/orm
  2. 2

    Run it

    • Check the official documentation for installation instructions
    • Install the library into a PHP project using Composer, as described in the documentation
    • Define a PHP class and map it to a database table
    • Use the entity manager to persist and query your objects
  3. 3

    Get the most out of it

    • Read the Doctrine ORM documentation for mapping and DQL details
    • Pair it with the Doctrine DBAL it is built on for lower-level database control
    • Choose the branch that matches your PHP and framework version, since several are maintained

Downloads

Strengths

  • Transparent persistence means your PHP objects are the main thing you work with
  • DQL offers an object-oriented query option that avoids duplicating SQL logic
  • The README lists several maintained branches with CI build and coverage badges

Trade-offs

  • Requires PHP 8.1 or newer, so older PHP projects may need upgrades first
  • The README is brief on setup; detailed usage lives in the external documentation site
  • Learning mapping configuration and DQL takes time for those new to ORMs

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.