PHPackages                             herdianrony/mongolite - 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. herdianrony/mongolite

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

herdianrony/mongolite
=====================

MongoDB-like interface with SQLite backend

v1.0.0(7mo ago)13MITPHPPHP &gt;=8.0

Since Sep 28Pushed 7mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

MongoLite
=========

[](#mongolite)

[![PHP Version](https://camo.githubusercontent.com/d4b5fa4adf514144779a7864904c5e15236c0e798635240c7f6ce9a455657b80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

> **High-performance MongoDB-compatible query engine with SQLite backend**

MongoLite is a lightweight, production-ready library that provides MongoDB-style queries and aggregations using SQLite as the storage engine. Originally developed as part of [Cockpit CMS](https://github.com/agentejo/cockpit), it has been extracted and enhanced as a standalone library.

🔍 About
-------

[](#-about)

This library was originally part of the [Cockpit CMS](https://github.com/agentejo/cockpit) project. It has been extracted, improved, and is now maintained as a separate package for broader use in PHP applications that need a lightweight, file-based NoSQL solution.

✨ Features
----------

[](#-features)

### 🔍 **Query Engine**

[](#-query-engine)

- **25+ Query Operators**: Complete support for MongoDB query syntax
- **Advanced Filtering**: `$and`, `$or`, `$not`, `$nor`, `$where`, `$expr`
- **Comparison Operators**: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`
- **Array Operators**: `$in`, `$nin`, `$all`, `$size`, `$elemMatch`
- **Pattern Matching**: `$regex`, `$text` with fuzzy search
- **Field Validation**: `$exists`, `$type`, `$mod`

### 📊 **Aggregation Framework**

[](#-aggregation-framework)

- **18+ Pipeline Stages**: Complete aggregation pipeline support
- **10 Accumulator Operators**: `$sum`, `$avg`, `$min`, `$max`, `$first`, `$last`, `$push`, `$addToSet`, `$stdDevPop`, `$stdDevSamp`
- **Data Transformation**: `$project`, `$addFields`, `$unset`, `$unwind`
- **Grouping &amp; Sorting**: `$group`, `$sort`, `$sortByCount`, `$bucket`
- **Sampling &amp; Analysis**: `$sample`, `$facet`, `$count`
- **Joins**: `$lookup` for data relationships

### 🌍 **Geospatial Support**

[](#-geospatial-support)

- **Location Queries**: `$near`, `$geoWithin`, `$geoIntersects`
- **Geometric Shapes**: Point, Polygon, Circle, Box support
- **Distance Calculations**: Haversine formula for accurate distances
- **Aggregation Integration**: `$geoNear` pipeline stage

### 📤 **Output Stages**

[](#-output-stages)

- **Data Export**: `$out` stage for collection replacement
- **Data Merging**: `$merge` stage with conflict resolution
- **Flexible Options**: `whenMatched`, `whenNotMatched` behaviors

### 🔒 **Security &amp; Performance**

[](#-security--performance)

- **SQL Injection Protection**: Comprehensive input sanitization
- **Memory Efficient**: Optimized for large dataset processing
- **Production Ready**: Tested with 1000+ record datasets
- **Error Resilient**: Graceful handling of edge cases

🚀 Quick Start
-------------

[](#-quick-start)

### Basic Usage

[](#basic-usage)

```
