PHPackages                             shockraver/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. shockraver/mongodb

ActiveCakephp-plugin

shockraver/mongodb
==================

An Mongodb datasource for CakePHP 3 and 4

1.5.1(1y ago)035.0k—0%3MITPHPPHP ^7.4

Since Apr 13Pushed 1y agoCompare

[ Source](https://github.com/ShockRaver/mongodb-cakephp3)[ Packagist](https://packagist.org/packages/shockraver/mongodb)[ RSS](/packages/shockraver-mongodb/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (3)Versions (11)Used By (0)

[![Slack](https://camo.githubusercontent.com/5491c20e06cd4dbfe3d53f66e9214c7b321834b81e6e1fd3e0ebbfb06e27ff95/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e253230746865253230636f6e766572736174696f6e2d6f6e253230736c61636b2d677265656e2e737667)](https://mongodb-cakephp3.slack.com/messages/general/)

Mongodb for Cakephp 3 and 4
===========================

[](#mongodb-for-cakephp-3-and-4)

An Mongodb datasource for CakePHP 3 and 4

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

[](#installing-via-composer)

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

```
composer require shockraver/mongodb
```

Connecting the Plugin to your application
-----------------------------------------

[](#connecting-the-plugin-to-your-application)

add the following line in your config/bootstrap.php to tell your application to load the plugin:

```
Plugin::load('Giginc/Mongodb');
```

Defining a connection
---------------------

[](#defining-a-connection)

Now, you need to set the connection in your config/app.php file:

```
 'Datasources' => [
    'default' => [
        'className' => 'Giginc\Mongodb\Database\Connection',
        'driver' => 'Giginc\Mongodb\Database\Driver\Mongodb',
        'persistent' => false,
        'host' => 'localhost',
        'port' => 27017,
        'username' => '',
        '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 Giginc\\Mongodb\\ORM\\Table in your tables class:

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

use Giginc\Mongodb\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

36

↑

LowBetter than 83% of packages

Maintenance40

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~77 days

Total

9

Last Release

500d ago

PHP version history (2 changes)1.0.0PHP ^5.4|^7.0

1.5PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/c29c8d3746c4063b63acaa382c206fab75b5b3748f06633c8ea52db6fae71417?d=identicon)[ShockRaver](/maintainers/ShockRaver)

---

Top Contributors

[![tiaguinho](https://avatars.githubusercontent.com/u/961553?v=4)](https://github.com/tiaguinho "tiaguinho (24 commits)")[![ludeus](https://avatars.githubusercontent.com/u/7382872?v=4)](https://github.com/ludeus "ludeus (22 commits)")[![delamux](https://avatars.githubusercontent.com/u/14236919?v=4)](https://github.com/delamux "delamux (8 commits)")[![gig-shogo-ishikura](https://avatars.githubusercontent.com/u/107465543?v=4)](https://github.com/gig-shogo-ishikura "gig-shogo-ishikura (7 commits)")[![issys16](https://avatars.githubusercontent.com/u/730772?v=4)](https://github.com/issys16 "issys16 (7 commits)")[![ShockRaver](https://avatars.githubusercontent.com/u/12100526?v=4)](https://github.com/ShockRaver "ShockRaver (6 commits)")[![SocialITGit](https://avatars.githubusercontent.com/u/45766355?v=4)](https://github.com/SocialITGit "SocialITGit (4 commits)")[![kawaiidesune](https://avatars.githubusercontent.com/u/13595774?v=4)](https://github.com/kawaiidesune "kawaiidesune (3 commits)")[![j3ll3nl](https://avatars.githubusercontent.com/u/10446794?v=4)](https://github.com/j3ll3nl "j3ll3nl (3 commits)")[![kgws](https://avatars.githubusercontent.com/u/83611?v=4)](https://github.com/kgws "kgws (2 commits)")[![ignaciocarre](https://avatars.githubusercontent.com/u/358968?v=4)](https://github.com/ignaciocarre "ignaciocarre (2 commits)")[![lexdewilligen](https://avatars.githubusercontent.com/u/31687602?v=4)](https://github.com/lexdewilligen "lexdewilligen (1 commits)")[![abdelatnova](https://avatars.githubusercontent.com/u/37415353?v=4)](https://github.com/abdelatnova "abdelatnova (1 commits)")[![johnjcamilleri](https://avatars.githubusercontent.com/u/376723?v=4)](https://github.com/johnjcamilleri "johnjcamilleri (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shockraver-mongodb/health.svg)

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

###  Alternatives

[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k22.8M268](/packages/doctrine-mongodb-odm)[snelg/cakephp-3-oracle

Oracle datasource for CakePHP 3

111.5k](/packages/snelg-cakephp-3-oracle)

PHPackages © 2026

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