PHPackages                             yaknet/mock-engine - 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. yaknet/mock-engine

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

yaknet/mock-engine
==================

In-memory SQL-like query builder and execution engine for PHP arrays

v1.0.4(2w ago)04MITPHPPHP &gt;=8.1

Since May 31Pushed 2w agoCompare

[ Source](https://github.com/y-packages/mock-engine)[ Packagist](https://packagist.org/packages/yaknet/mock-engine)[ RSS](/packages/yaknet-mock-engine/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

MockEngine
==========

[](#mockengine)

[![Latest Version on Packagist](https://camo.githubusercontent.com/03b1c47b04520f27f2f969073aac89ebcb975b5b38c21f7775c68a675f0b9e90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79616b6e65742f6d6f636b2d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yaknet/mock-engine)[![Total Downloads](https://camo.githubusercontent.com/ea874160a3e337b9a4c9419eee20b9d12c291adf2b675b7ffe867606486fa3a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79616b6e65742f6d6f636b2d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yaknet/mock-engine)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

**MockEngine** is a lightweight, pure PHP (PHP 8.1+) in-memory query engine that lets you filter, sort, join, group, and aggregate raw arrays or object lists using an elegant, Laravel/Symfony-style fluent Query Builder—completely without any database overhead!

It is perfect for unit testing, in-memory caching systems, sorting baskets in e-commerce, or managing nested datasets in microservices.

---

Features
--------

[](#features)

- ✨ **Fluent Query Builder:** Build queries using `where()`, `orWhere()`, `select()`, `orderBy()`, `limit()`, `groupBy()`, `join()`, and `leftJoin()`.
- 🎯 **Point Notation (Nested Access):** Query nested arrays or objects instantly, e.g., `where('profile.address.city', '=', 'Istanbul')`.
- ⚙️ **Advanced Operators:** Support for `=`, `!=`, `>`, `=`, ` 1, 'name' => 'John Doe', 'role' => 'admin', 'profile' => ['city' => 'Istanbul']],
    ['id' => 2, 'name' => 'Jane Smith', 'role' => 'user', 'profile' => ['city' => 'Ankara']],
    ['id' => 3, 'name' => 'Bob Johnson', 'role' => 'user', 'profile' => ['city' => 'Izmir']],
];

// Query active admins in Istanbul
$results = QueryBuilder::from($users)
    ->select('id', 'name', 'profile.city as city')
    ->where('role', '=', 'user')
    ->where('profile.city', '!=', 'Ankara')
    ->get();

// Returns a Collection containing:
// [ ['id' => 3, 'name' => 'Bob Johnson', 'city' => 'Izmir'] ]
```

### 2. Complex &amp; Nested Logical Groups (AND / OR)

[](#2-complex--nested-logical-groups-and--or)

You can group logical operations together by passing a `Closure` to `where` or `orWhere`:

```
$results = QueryBuilder::from($users)
    ->where('status', '=', 'active')
    ->where(function (QueryBuilder $query) {
        $query->where('role', '=', 'admin')
              ->orWhere('profile.verified', '=', true);
    })
    ->get();
```

### 3. Joining Two Collections (INNER / LEFT JOIN)

[](#3-joining-two-collections-inner--left-join)

```
$posts = [
    ['id' => 101, 'user_id' => 1, 'title' => 'First Post'],
    ['id' => 102, 'user_id' => 1, 'title' => 'Second Post'],
    ['id' => 103, 'user_id' => 2, 'title' => 'Hello World'],
];

// Perform INNER JOIN
$results = QueryBuilder::from($users)
    ->select('name', 'title')
    ->join($posts, 'id', '=', 'user_id')
    ->get();
```

### 4. Grouping &amp; Collection Aggregations

[](#4-grouping--collection-aggregations)

If you use `groupBy()`, the results will be grouped into a nested Collection of Collections:

```
$grouped = QueryBuilder::from($users)
    ->groupBy('profile.city')
    ->get();

// Get the average age of users in Istanbul
$istanbulUsers = $grouped['Istanbul']; // This is a Collection!
$averageAge = $istanbulUsers->avg('age');
$maxAge = $istanbulUsers->max('age');
$names = $istanbulUsers->pluck('name'); // ['John Doe', ...]
```

---

Running Tests
-------------

[](#running-tests)

All features are fully verified with a comprehensive unit test suite:

```
vendor/bin/phpunit
```

License
-------

[](#license)

This project is licensed under the MIT License. See [LICENSE.md](LICENSE.md) for details.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance96

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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.

###  Release Activity

Cadence

Every ~9 days

Total

5

Last Release

17d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/236650944?v=4)[yakistir98](/maintainers/yakistir98)[@yakistir98](https://github.com/yakistir98)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yaknet-mock-engine/health.svg)

```
[![Health](https://phpackages.com/badges/yaknet-mock-engine/health.svg)](https://phpackages.com/packages/yaknet-mock-engine)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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