crustum / cakephp-mongo-odm
MongoDB ODM for CakePHP: Cake-style collections, documents, fluent query builder over aggregation pipelines, associations, behaviors, validation, migrations, Bake code generation and an ORM bridge
Package info
github.com/Crustum/cakephp-mongo-odm
Type:cakephp-plugin
pkg:composer/crustum/cakephp-mongo-odm
Requires
- php: >=8.4
- cakephp/bake: ^3.7
- cakephp/cakephp: ^5.4
- mongodb/mongodb: ^2.0
Requires (Dev)
- boundwize/structarmed: ^0.14
- brianium/paratest: ^7.20
- cakedc/cakephp-phpstan: ^4.3
- cakephp/cakephp-codesniffer: ^5.0
- cakephp/mago-rules: dev-main
- crustum/debug-bar: dev-main
- crustum/essentia: ^1.0
- crustum/explorator: ^1.0
- crustum/ignis: ^1.0
- crustum/plugin-manifest: ^1.2
- mockery/mockery: ^1.6.12
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^10.5 || ^11.1 || ^12.5
- rector/rector: ^2.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
CakePHP Mongo is a MongoDB ODM with direct ORM parity. Collections correspond to tables and documents to entities, with the same find, save and delete flow, validation, rules, behaviors, events and containable associations. ORM knowledge transfers without relearning, and MongoDB code follows the same conventions, locators and Bake workflows as SQL code.
Documents support nesting under a typed schema. Field types, indexes and JSON schema validators are defined through migrations, and validation runs against that schema. Alongside the classic hasOne, hasMany, belongsTo and belongsToMany, the ODM adds embedOne and embedMany for data stored inside the parent document, plus DBRef references. Queries compile to find and aggregation pipelines, with lookup based eager loading, full text, geospatial and vector search, JSON schema validation, versioned migrations, and transactions.
Mixed SQL and MongoDB applications are supported through an ORM to ODM association bridge. Tables and collections link across the boundary with contain loading, cascade delete and controlled saves. Mongo backed cache, lock and session engines are included, with standalone, replica set and Atlas deployments covered.
Requirements
- PHP 8.4+
See Versions.md for the supported CakePHP versions.
Installation
Installation into a CakePHP application is done with composer:
composer require crustum/cakephp-mongo-odm
Load the plugin:
bin/cake plugin load Crustum/Mongo
Documentation
For documentation, as well as tutorials, see the docs directory of this repository.
License
Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.