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

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

hexcores/mongo-lite
===================

MongoDB Lite Pacakge

71482PHP

Since Feb 20Pushed 9y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Mongo Lite PHP
==============

[](#mongo-lite-php)

Mongo Lite PHP is mongodb lite package for php.

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

[](#installation)

You can install library through Composer:

Add the following to the composer.json file...

```
{
    "require": {
        "hexcores/mongo-lite": "dev-master"
    }
}
```

Or

Install from terminal

```
$ composer require 'hexcores/mongo-lite:dev-master'

```

Usage
-----

[](#usage)

You need to configure Mongodb connection at first step.

```
$host = 'localhost';
$port = 27017;
$database = 'mongo_lite';

Hexcores\MongoLite\Connection::connect($host, $port, $database);
```

Now we can use Mongo Lite.

```
$connection = \Hexcores\MongoLite\Connection::instance($name);
$userCollection = new \Hexcores\MongoLite\Query($connection->collection('users'));
// or simply
$userCollection  = mongo_lite('users');
```

### CRUD with MongoLite

[](#crud-with-mongolite)

#### Create new record

[](#create-new-record)

*`"created_at"` and `"updated_at"` fields will be auto filled by `mongo_lite`*

```
$user = ['name' => 'Nyan', 'email' => 'nyan@example.com'];

$userCollection  = mongo_lite('users');
$userCollection->insert($user);
// or simply
mongo_lite_insert('users', $user);
```

#### Update a record

[](#update-a-record)

*`mongo_lite` will be auto update for `updated_at` time*

```
$updateName = ['name' => 'Lynn'];
$query = ['email' => 'nyan@exmapl.com'];

$userCollection  = mongo_lite('users');
$userCollection->update($query, $updateName);
// or simply
mongo_lite_update('users', $query, $updateName);
```

#### Delete a record

[](#delete-a-record)

```
$query = ['email' => 'nyan@exmapl.com'];

$userCollection  = mongo_lite('users');
$userCollection->delete($query);
// or simply
mongo_lite_delete('users', $query);
```

#### Find the record from database

[](#find-the-record-from-database)

Find all users from collection.

```
$users = mongo_lite('users')->all();

if ( count($users) > 0)
{
	foreach ( $users as $user)
	{
		echo $user->name . '';
	}
}
```

Find only one record from database.

```
// Find user by mongo id string
$user = mongo_lite('users')->first('5579227f8e973cdf148b4567');

// Find user by MongoId instance
$user = mongo_lite('users')->first(new MongoId('5579227f8e973cdf148b4567'));

// Find user by email
$user = mongo_lite('users')->first(['email' => 'nyan@example.com']);

echo $user->name;
```

#### Increment and decrement of MongoDB

[](#increment-and-decrement-of-mongodb)

```
// Increment value 1 to page view field where 'slug' is equal 'about'
$page->increment(['slug' => 'about'], 'views');

// Increment value 5 to page view field where 'slug' is equal 'about'
$page->increment(['slug' => 'about'], 'views', 5);

// Decrement value 1 to page view field where 'slug' is equal 'about'
$page->increment(['slug' => 'about'], 'views', -1);

// DEcrement value 5 to page view field where 'slug' is equal 'about'
$page->increment(['slug' => 'about'], 'views', -5);
```

#### Using in Laravel and LumenPHP

[](#using-in-laravel-and-lumenphp)

MongoLite already have a `ServiceProvider` for Laravel and LumenPHP Framework.

```
// Add ServiceProvider in 'config\app.php'
Hexcores\MongoLite\Laravel\MongoLiteServiceProvider
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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/29fb608c623105faf35af0f3e476475691ae2ae377c55f1ae62fae9e959a8848?d=identicon)[nyanlynnhtut](/maintainers/nyanlynnhtut)

---

Top Contributors

[![nyanlynnhtut](https://avatars.githubusercontent.com/u/1456363?v=4)](https://github.com/nyanlynnhtut "nyanlynnhtut (24 commits)")[![DragonVirus](https://avatars.githubusercontent.com/u/1311765?v=4)](https://github.com/DragonVirus "DragonVirus (3 commits)")[![ThetPaing](https://avatars.githubusercontent.com/u/2143128?v=4)](https://github.com/ThetPaing "ThetPaing (3 commits)")

### Embed Badge

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

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

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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