Patchlevel ODM is a lightweight Object Document Mapper for PHP. It maps plain PHP objects to document storage and runs on both MongoDB and PostgreSQL (through patchlevel/rango), exposing the same API for both. It is built on top of patchlevel/hydrator, which gives you fast attribute-based mapping and enterprise features like encryption out of the box.
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.
#[Document] and #[Id]#[Index], including unique constraintsInstall the library with Composer. Depending on your database, you also need the matching driver package.
For PostgreSQL via Rango:
composer require patchlevel/odm patchlevel/rangoFor MongoDB:
composer require patchlevel/odm mongodb/mongodbNew to the library? The getting started guide builds a complete example from defining a document to querying it.