PHPackages                             patchlevel/odm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. patchlevel/odm

ActiveLibrary[Database &amp; ORM](/categories/database)

patchlevel/odm
==============

A lightweight Object Document Mapper for PHP that runs on both MongoDB and PostgreSQL with one consistent API

1.0.0(3mo ago)42.4k↑300%[1 PRs](https://github.com/patchlevel/odm/pulls)MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Mar 10Pushed 1mo agoCompare

[ Source](https://github.com/patchlevel/odm)[ Packagist](https://packagist.org/packages/patchlevel/odm)[ Docs](https://github.com/patchlevel/odm)[ RSS](/packages/patchlevel-odm/feed)WikiDiscussions 1.1.x Synced 1w ago

READMEChangelog (5)Dependencies (22)Versions (10)Used By (0)

[![Mutation testing badge](https://camo.githubusercontent.com/3dc81ac4bebad10d1ec985ecb5d71e9fb30bc89289d431d12736cb9f9dff6912/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324670617463686c6576656c2532466f646d253246312e302e78)](https://dashboard.stryker-mutator.io/reports/github.com/patchlevel/odm/1.0.x)[![Latest Stable Version](https://camo.githubusercontent.com/603e88cbe700afdd0983305d896c022638e04f86cb3edf0e3cf1ab3ab70a6b39/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6f646d2f76)](//packagist.org/packages/patchlevel/odm)[![License](https://camo.githubusercontent.com/701dfe3fd6d42371d3370cf9aab65de628806ca98b141d642f769e2b40c347e6/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6f646d2f6c6963656e7365)](//packagist.org/packages/patchlevel/odm)

Patchlevel ODM
==============

[](#patchlevel-odm)

Patchlevel ODM is a lightweight **Object Document Mapper (ODM)** for PHP that works with **MongoDB** and **PostgreSQL** (via [patchlevel/rango](https://github.com/patchlevel/rango/)). It is built on top of our superfast **[patchlevel/hydrator](https://github.com/patchlevel/hydrator/)**, providing a simple attribute-based mapping layer and enterprise-grade features like cryptography.

Unlike Doctrine ODM, Patchlevel ODM has **no Unit of Work**. Repositories control persistence explicitly, so every write is deliberate and easy to reason about, which makes the library a good fit for long-running worker processes.

Features
--------

[](#features)

- [MongoDB and PostgreSQL support](https://patchlevel.dev/docs/odm/latest/databases) with a single, consistent API
- [Attribute-based document mapping](https://patchlevel.dev/docs/odm/latest/documents) with `#[Document]` and `#[Id]`
- [Repositories without a Unit of Work](https://patchlevel.dev/docs/odm/latest/repository) for predictable writes
- [Querying](https://patchlevel.dev/docs/odm/latest/repository#querying) with filters, sorting and pagination
- [Indexes](https://patchlevel.dev/docs/odm/latest/documents#indexes) defined with `#[Index]`, including unique constraints
- [Field mapping and normalization](https://patchlevel.dev/docs/odm/latest/field-mapping) for nested objects and custom field names
- [Encryption and crypto shredding](https://patchlevel.dev/docs/odm/latest/encryption) for sensitive data

Installation
------------

[](#installation)

```
composer require patchlevel/odm
```

Documentation
-------------

[](#documentation)

- Latest [Docs](https://patchlevel.dev/docs/odm/latest)
- Related [Blog](https://patchlevel.dev/blog)

Integration
-----------

[](#integration)

- [patchlevel/hydrator](https://github.com/patchlevel/hydrator)
- [patchlevel/rango](https://github.com/patchlevel/rango)

Contributing
------------

[](#contributing)

We are open to contributions as long as they are in line with our [BC-Policy](https://patchlevel.dev/our-backward-compatibility-promise).

Also note that the `composer.lock` is always generated with the newest supported PHP version as this is the version our tools run in the CI.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance85

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

7

Last Release

55d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/470138?v=4)[David Badura](/maintainers/DavidBadura)[@DavidBadura](https://github.com/DavidBadura)

---

Top Contributors

[![DavidBadura](https://avatars.githubusercontent.com/u/470138?v=4)](https://github.com/DavidBadura "DavidBadura (35 commits)")[![DanielBadura](https://avatars.githubusercontent.com/u/2017762?v=4)](https://github.com/DanielBadura "DanielBadura (11 commits)")

---

Tags

postgreshydratormongodbrango

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/patchlevel-odm/health.svg)

```
[![Health](https://phpackages.com/badges/patchlevel-odm/health.svg)](https://phpackages.com/packages/patchlevel-odm)
```

###  Alternatives

[mongodb/mongodb

MongoDB driver library

1.6k69.2M678](/packages/mongodb-mongodb)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k24.8M382](/packages/doctrine-mongodb-odm)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58926.6M60](/packages/scienta-doctrine-json-functions)[phpbu/phpbu

PHP Backup utility.

1.3k97.7k4](/packages/phpbu-phpbu)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

117550.1k6](/packages/apix-cache)[patchlevel/event-sourcing

A lightweight but also all-inclusive event sourcing library with a focus on developer experience

213396.3k15](/packages/patchlevel-event-sourcing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
