PHPackages                             nacer/mongodbcakephp - 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. nacer/mongodbcakephp

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

nacer/mongodbcakephp
====================

Mongodb datasource for CakePHP

05PHP

Since Mar 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/elbasri/mongodbcakephp)[ Packagist](https://packagist.org/packages/nacer/mongodbcakephp)[ RSS](/packages/nacer-mongodbcakephp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Mongodb DS for Cakephp
======================

[](#mongodb-ds-for-cakephp)

Installing via composer
-----------------------

[](#installing-via-composer)

Install [composer](http://getcomposer.org) and run:

```
composer require nacer/mongodbcakephp dev-master
```

Enable Plugin
-------------

[](#enable-plugin)

```
// open src/Application.php
// then add plugin like below

public function bootstrap()
{
    $this->addPlugin('Nacer/Mongodbcakephp');
}
```

Before of CakePHP 3.7 (3.5.\* &amp; 3.6.\*)

```
// at the end of this file config/bootstrap.php, add the code bellow

Plugin::load('Nacer/Mongodbcakephp');
```

Fill Default Datasource using mongodb auth infos
------------------------------------------------

[](#fill-default-datasource-using-mongodb-auth-infos)

```
// In config/app.php file, replace the default datasource using mongodb like below
 'Datasources' => [
    'default' => [
        'className' => 'Nacer\Mongodbcakephp\Database\Connection',
        'driver' => 'Nacer\Mongodbcakephp\Database\Driver\Mongodb',
        'persistent' => false,
        'host' => 'localhost',
        'port' => 27017,
        'login' => '',
        'password' => '',
        'database' => 'devmongo',
        'ssh_host' => '',
        'ssh_port' => 22,
        'ssh_user' => '',
        'ssh_password' => '',
        'ssh_pubkey_path' => '',
        'ssh_privatekey_path' => '',
        'ssh_pubkey_passphrase' => ''
    ],
],
```

### SSH tunnel variables (starting with 'ssh\_')

[](#ssh-tunnel-variables-starting-with-ssh_)

If you want to connect to MongoDB using a SSH tunnel, you need to set additional variables in your Datasource. Some variables are unnecessary, depending on how you intend to connect. IF you're connecting using a SSH key file, the `ssh_pubkey_path` and `ssh_privatekey_path` variables are necessary and the `ssh_password` variable is unnecessary. If you're connecting using a text-based password (which is **not** a wise idea), the reverse is true. The function needs, at minimum, `ssh_host`, `ssh_user` and one method of authentication to establish a SSH tunnel.

Models
------

[](#models)

After that, you need to load Nacer\\Mongodbcakephp\\ORM\\Table in your tables class:

```
//src/Model/Table/YourTable.php

use Nacer\Mongodbcakephp\ORM\Table;

class CategoriesTable extends Table {

}
```

Observations
------------

[](#observations)

The function find() works only in the old fashion way. So, if you want to find something, you to do like the example:

```
$this->Categories->find('all', ['conditions' => ['name' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name LIKE' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name' => 'teste'], 'limit' => 3]);
```

You can also use the advanced conditions of MongoDB using the `MongoDB\BSON` namespace

```
$this->Categories->find('all', ['conditions' => [
    '_id' => new \MongoDB\BSON\ObjectId('5a7861909db0b47d605c3865'),
    'foo.bar' => new \MongoDB\BSON\Regex('^(foo|bar)?baz$', 'i')
]]);
```

LICENSE
-------

[](#license)

[The MIT License (MIT) Copyright (c) 2013](http://opensource.org/licenses/MIT)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0327e9f2b7cea8ed8198e01e998779d4989b9978b52b1fa4ab64a66a9a229b07?d=identicon)[elbasri](/maintainers/elbasri)

---

Top Contributors

[![elbasri](https://avatars.githubusercontent.com/u/11248380?v=4)](https://github.com/elbasri "elbasri (5 commits)")

### Embed Badge

![Health badge](/badges/nacer-mongodbcakephp/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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