gitmyhub

orm

PHP ★ 10k updated 3h ago

Doctrine Object Relational Mapper (ORM)

Doctrine ORM is a PHP library that maps database tables to PHP objects so you can read and save data without writing raw SQL, widely used in Symfony projects, with version 3.0 currently in development.

PHPSQLDQLsetup: moderatecomplexity 3/5

Doctrine ORM is a library for PHP applications that handles the connection between code objects and a relational database. It is called an object-relational mapper because it maps the data stored in database tables onto PHP objects, letting developers work with data as normal objects in code instead of writing raw SQL queries.

The core idea is that a developer defines their data structures as PHP classes, and Doctrine handles reading those objects from the database and writing them back when changes are made. This is called transparent persistence: the developer works with regular PHP objects, and the library takes care of synchronizing them with the database behind the scenes.

For cases where developers need more control over database queries, Doctrine provides its own query language called DQL (Doctrine Query Language). DQL looks similar to SQL but operates on objects and their relationships rather than on raw table rows and columns. This makes complex queries easier to write when your data model is organized around objects.

Doctrine ORM sits on top of a separate database abstraction layer called DBAL, which handles the actual communication with the database engine. This separation means the ORM itself does not need to know the details of which database is being used.

The repository shown here is for the upcoming Doctrine 3.0, which contains significant changes from earlier versions. The stable releases at the time of the README were the 2.7 and 2.8 branches. Doctrine ORM is a widely used library in the PHP ecosystem, particularly in projects built with the Symfony framework, though it works independently as well.

Where it fits