patchlevel / odm
A lightweight Object Document Mapper for PHP that runs on both MongoDB and PostgreSQL with one consistent API
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- patchlevel/hydrator: ^1.23.0
Requires (Dev)
- ext-mongodb: ^2.1
- infection/infection: ^0.32.6
- mongodb/mongodb: ^2.1
- patchlevel/coding-standard: ^1.3.0
- patchlevel/rango: 1.0.0-alpha.4
- phpat/phpat: ^0.12.4
- phpbench/phpbench: ^1.6.1
- phpstan/phpstan: ^2.1.46
- phpstan/phpstan-phpunit: ^2.0.16
- phpunit/phpunit: ^11.5.55
- symfony/var-dumper: ^v7.4.8 || ^v8.0.0
This package is auto-updated.
Last update: 2026-06-16 19:12:03 UTC
README
Patchlevel ODM
Patchlevel ODM is a lightweight Object Document Mapper (ODM) for PHP that works with MongoDB and PostgreSQL (via patchlevel/rango). It is built on top of our superfast 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
- MongoDB and PostgreSQL support with a single, consistent API
- Attribute-based document mapping with
#[Document]and#[Id] - Repositories without a Unit of Work for predictable writes
- Querying with filters, sorting and pagination
- Indexes defined with
#[Index], including unique constraints - Field mapping and normalization for nested objects and custom field names
- Encryption and crypto shredding for sensitive data
Installation
composer require patchlevel/odm
Documentation
Integration
Contributing
We are open to contributions as long as they are in line with our BC-Policy.
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.