PHPackages                             owlgrin/mongo - 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. owlgrin/mongo

ActiveLibrary[Database &amp; ORM](/categories/database)

owlgrin/mongo
=============

Minimal Mongo Client for Laravel

21.0k1[1 issues](https://github.com/owlgrin/mongo/issues)PHP

Since Aug 20Pushed 11y ago2 watchersCompare

[ Source](https://github.com/owlgrin/mongo)[ Packagist](https://packagist.org/packages/owlgrin/mongo)[ RSS](/packages/owlgrin-mongo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Mongo
=====

[](#mongo)

Minimal MongoDb for Laravel apps.

This package provides simple to use MongoDB structure and authentication, to get you started with MongoDB in Laravel in less than 10 seconds.

### Installation

[](#installation)

You can install this package by requiring it in your composer.json.

```
"owlgrin/mongo": "dev-master"
```

The add the following service provider in your `app.php` configuration file.

```
'Owlgrin\Mongo\MongoServiceProvider'
```

Lastly, you will have to list out your MongoDb connection credentials in your `database.php` configuration file. Add the connections like so:

```
...
'connections' => array(
	...
	'mongo' => array(
		'driver'   => 'mongo',
		'host'     => 'localhost',
		'port'     => 27017,
		'username' => 'username',
		'password' => 'password',
		'database' => 'dbname'
	)
)
```

To leverage the benefits of replica sets, you can describe the configuration like this:

```
...
'connections' => array(
	...
	'mongo' => array(
		'driver'   => 'mongo',
		'host'     => array('server1', 'server2'),
		'port'     => 27017,
		'username' => 'username',
		'password' => 'password',
		'database' => 'experiment',
		'options'  => array('replicaSet' => 'someReplicaSet')
	)
)
```

### Usage

[](#usage)

With this package, you can use MongoDb like this:

```
$user = DB::connection('mongo')
	->users
	->find(array('is_active' => 1));
```

If you are using MongoDb exclusively, you can set the `default` property in `database.php` configuration file to `mongo`, to make the usage easier, like so:

```
$users = DB::collection('users')->find(array('is_active' => 1));
```

### Authentication

[](#authentication)

This package comes bundled with the authentication driver for MongoDB. To set it up, do these steps.

1. Change the driver in `app/config/auth.php` to 'mongo';

```
'driver' => 'mongo'
```

2. Next, add these two properties (probably next to 'table' property) in the same `app/config/auth.php` file.

```
/*
|--------------------------------------------------------------------------
| Authentication Collection
|--------------------------------------------------------------------------
|
| When using the "Mongo" authentication driver, we need to know which
| collection should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/

'collection' => 'users',

/*
|--------------------------------------------------------------------------
| Hashed or Encrypted Password
|--------------------------------------------------------------------------
|
| In some cases, you may need to store passwords encrypted as opposed to
| hashed generally. For instance, API secret keys for your users can be stored
| encrypted and not hashed, as they are to be decrypted and shown to
| users in their accounts (and storing them in plain text is a very bad idea).
| By default, we assume that the password will be hashed. If it is encrypted,
| set the following option to true.
|
*/

'encrypted_password' => false,
```

That's it! Now, you can authenticate your users using MongoDB. No other change is required in your whole code - it just works!

---

We are not sure, if we will extend the functionalities of this package. We wanted something to get started quickly. If you want something more extensive, Jens has a great package for you: .

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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://avatars.githubusercontent.com/u/4389133?v=4)[Owlgrin](/maintainers/owlgrin)[@owlgrin](https://github.com/owlgrin)

---

Top Contributors

[![mohitmamoria](https://avatars.githubusercontent.com/u/2756694?v=4)](https://github.com/mohitmamoria "mohitmamoria (11 commits)")

### Embed Badge

![Health badge](/badges/owlgrin-mongo/health.svg)

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

###  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)
