A query builder composes SQL from method calls, which helps when optional filters change the shape of the WHERE clause per request. An ORM maps rows to objects and tracks their changes: active record puts save() on the model, while a data mapper keeps entities as plain objects and persists them through a separate manager. All four below run on PDO and are MIT licensed.
| Library | Kind | Release (Packagist 4,624 ) | PHP |
|---|---|---|---|
| Doctrine DBAL 9,705 | Query builder, schema tools | 4.4.4 (21 Jul 2026) | 8.2+ |
| Doctrine ORM 159,716 | Data mapper, unit of work | 3.7.2 (23 Sep 2026) | 8.1+ |
| Eloquent (illuminate/database) | Active record | 13.33.0 (18 Sep 2026) | 8.3+ |
| Cycle ORM 1,329 | Data mapper | 2.18.0 (15 Jun 2026) | 8.1+ |
Install each with composer require and its package name (doctrine/dbal (https://github.com/doctrine/dbal 9,705 ), doctrine/orm (https://github.com/doctrine/orm 10,165 ), illuminate/database (https://github.com/illuminate/database 2,774 ), cycle/orm (https://github.com/cycle/orm 1,329 )). Adopt one when you write the same mapping code for the tenth table or when relations and eager loading dominate. Stay with PDO for reports full of window functions and CTEs (MySQL), and read the SQL any ORM generates: the N+1 problem, one query per row of a list, is its classic cost. Laravel teaches Eloquent.