PHPackages                             giginc/cakephp5-driver-mongodb - 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. giginc/cakephp5-driver-mongodb

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

giginc/cakephp5-driver-mongodb
==============================

MongoDB datasource driver for CakePHP 5 (modern successor to giginc/mongodb).

1.0.0(1mo ago)0126↓66.7%MITPHPPHP ^8.2CI passing

Since Apr 17Pushed 1mo agoCompare

[ Source](https://github.com/giginc/cakephp5-driver-mongodb)[ Packagist](https://packagist.org/packages/giginc/cakephp5-driver-mongodb)[ Docs](https://github.com/giginc/cakephp5-driver-mongodb)[ RSS](/packages/giginc-cakephp5-driver-mongodb/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

cakephp5-driver-mongodb
=======================

[](#cakephp5-driver-mongodb)

MongoDB datasource driver for **CakePHP 5** — the modern successor to [giginc/mongodb](https://github.com/giginc/mongodb-cakephp3).

Targets PHP 8.1+, CakePHP 5, and `mongodb/mongodb` 2.x. The public API follows CakePHP 5 conventions (fluent query builder, marshaller, entities) and does **not** preserve the array-based call style of the v3 plugin.

> **Status:** scaffold / work in progress. Connection + Driver + Table base + Marshaller/Entity conversion are in scope. Associations, behaviors, and SSH tunnelling are deferred to a later release.

Requirements
------------

[](#requirements)

- PHP `^8.1`
- `ext-mongodb`
- `mongodb/mongodb` `^2.0`
- `cakephp/cakephp` `^5.0`

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

[](#installation)

```
composer require giginc/cakephp5-driver-mongodb
```

Then load the plugin (optional — the package only contributes a Connection/ Driver/Table base, so loading is not strictly required):

```
bin/cake plugin load Giginc/Mongodb
```

Configuration
-------------

[](#configuration)

In `config/app.php`:

```
'Datasources' => [
    'mongo' => [
        'className' => \Giginc\Mongodb\Database\Connection::class,
        'driver'    => \Giginc\Mongodb\Database\Driver\Mongodb::class,
        'host'      => 'localhost',
        'port'      => 27017,
        'database'  => 'my_database',
        'username'  => '',
        'password'  => '',
        // or a full DSN that wins over host/port/auth:
        // 'uri'    => 'mongodb://user:pass@host:27017/my_database?authSource=admin',
    ],
],
```

Usage
-----

[](#usage)

```
// src/Model/Table/UsersTable.php
