What is ORM?

ORM (Object-relational mapping), also known as O/RM, and O/R mapping is a programming approach for converting data between incompatible type systems.

Many full stack frameworks provide their own database abstraction approaches or ORMs.

Standalone database abstraction layers and ORMs to check out:

  • Aura SQL - Extension to the native PDO along with a profiler and connection locator.
  • DataMonkey - Database ORM for PHP build on top of Doctrine.
  • Doctrine - Home to several PHP libraries primarily focused on database storage and object mapping. The core projects are a Object Relational Mapper (ORM) and the Database Abstraction Layer (DBAL) it is built upon.
  • Eloquent - Illuminate Database component, used in Laravel framework but also a standalone component.
  • Medoo - Light PHP database framework to accelerate development.
  • Pomm - PHP Object Model Manager for Postgresql.
  • Propel - A highly customizable and blazing fast ORM library.
  • ProxyManager - Library that aims at providing abstraction for generating various kinds of proxy classes.
  • RedBeanPHP - Easy to use ORM for PHP.
  • safemysql - A real safe and convenient way to handle MySQL queries.
  • Spot ORM - simple and efficient DataMapper built on Doctrine Database Abstraction Layer.
  • Zend\Db - Zend Database Component.

Design patterns

There are mainly two main design patterns used in ORMs - Active Record and Data Mapper.

When not to use ORM?

As some articles have pointed out (1, 2, 3), ORM is anti-pattern that violates principles of object-oriented programming.

See also

Here are some other useful and updated resources to read or check as well:

GitHub OctocatFound a typo? Something wrong with this content? Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all the contributors.