PHPackages                             masan27/laravel-redis-om - 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. masan27/laravel-redis-om

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

masan27/laravel-redis-om
========================

Laravel Redis OM implementation for Laravel with direct RediSearch support

2.3.6(3w ago)067—0%proprietaryPHPPHP ^8.0

Since Mar 25Pushed 3w agoCompare

[ Source](https://github.com/masan27/laravel-redis-om)[ Packagist](https://packagist.org/packages/masan27/laravel-redis-om)[ Docs](https://github.com/masan27/laravel-redis-om)[ RSS](/packages/masan27-laravel-redis-om/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (13)Versions (23)Used By (0)

Laravel Redis OM
================

[](#laravel-redis-om)

A high-performance **Pure PHP** Redis Object Mapper (OM) for Laravel, powered by RedisJSON and RediSearch. This library provides an Eloquent-like experience with zero external dependencies other than Redis itself.

Features
--------

[](#features)

- **Direct Redis Access**: Performance-critical operations (`find`, `save`, `update`, `delete`) interact directly with Redis using `JSON.GET/SET`.
- **Search &amp; Pagination**: Full support for RediSearch filtering, sorting, and various pagination styles.
- **Transaction Support**: Group multiple operations like (`begin`,`commit`,`rollback`).
- **Atomic Updates**: Partial updates are performed atomically using RedisJSON paths.
- **Eager Loading**: Supports record relationships (`hasOne`, `hasMany`) and eager loading with `with()`.

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

[](#installation)

Install the package via Composer:

```
composer require masan27/laravel-redis-om
```

Configuration
-------------

[](#configuration)

Complete the installation and publish the config file:

```
php artisan redis-om:install
```

This command will publish the `config/redis_om.php` file and add necessary environment variables to your `.env`.

```
return [
    'connection'   => env('REDIS_OM_CONNECTION', 'default'),
    'index_suffix' => 'index',
];
```

Creating Models
---------------

[](#creating-models)

You can quickly generate a new Redis OM model class using the following artisan command:

```
php artisan redis-om:model {name}
```

**Example:**

```
php artisan redis-om:model User
```

This will create `app/Models/RedisOM/User.php`. You can also use subdirectories: `php artisan redis-om:model Products/Electronic`.

Migrating Indexes
-----------------

[](#migrating-indexes)

Since this is a Schema-based OM, you must create RediSearch indexes before querying. Run the following command whenever you add or update the `$index` property in your models:

```
php artisan redis-om:migrate
```

Use `--force` to drop and recreate existing indexes.

Basic Usage
-----------

[](#basic-usage)

### Defining a Model

[](#defining-a-model)

```
namespace App\Models\RedisOM;

use Masan27\LaravelRedisOM\RedisOM;

class User extends RedisOM
{
    protected array $index = [
        'name'   => 'TEXT',
        'email'  => 'TAG',
        'age'    => 'NUMERIC',
        'status' => 'TAG',
    ];
}
```

### CRUD Operations

[](#crud-operations)

```
// Create
$user = User::create(['id' => 1, 'name' => 'Sian', 'status' => 'active']);

// Find
$user = User::find(1);

// Update
$user->status = 'inactive';
$user->save();

// Delete
$user->delete();
```

### Querying

[](#querying)

```
// Fluent Query Building
$users = User::query()
    ->where('status', 'active')
    ->where('age', '>=', 18)
    ->whereStartsWith('name', 'Sia')
    ->whereFuzzy('name', 'Sian') // Typo Tolerance / Fuzzy Search (defaults to 'auto' dynamic distance)
    ->orderBy('age', 'desc')
    ->get();

// Pagination
$paginated = User::query()->paginate(15);
```

Debugging &amp; Query Logging
-----------------------------

[](#debugging--query-logging)

### Query Log

[](#query-log)

You can enable the query log to capture all raw Redis commands executed during a request. This is useful for debugging and performance profiling.

```
use Masan27\LaravelRedisOM\RedisOM;

// Enable logging
RedisOM::enableQueryLog();

// Run some queries
$user = User::find(1);
$activeUsers = User::where('status', 'active')->get();

// Get the log
$logs = RedisOM::getQueryLog();
/*
[
    [
        'query'      => 'JSON.GET users:1',
        'time'       => 0.45, // in milliseconds
        'connection' => 'default'
    ],
    [
        'query'      => 'FT.SEARCH users:index "@status:{active}" LIMIT 0 10',
        'time'       => 1.2,
        'connection' => 'default'
    ]
]
*/

// Clear the log
RedisOM::flushQueryLog();

// Disable logging
RedisOM::disableQueryLog();
```

### Raw Query Preview

[](#raw-query-preview)

If you want to see the `FT.SEARCH` command that will be executed by the query builder without actually running it:

```
$query = User::where('status', 'active')->where('age', '>', 20);

echo $query->getRawQuery();
// Output: FT.SEARCH users:index "@status:{active} @age:[(20 +inf]" LIMIT 0 10
```

Documentation &amp; Examples
----------------------------

[](#documentation--examples)

Detailed usage examples:

- [**CRUD Operations**](examples/model/crud.md) — Finding, saving, updating, and deleting.
- [**Querying &amp; Pagination**](examples/model/query.md) — Filtering, sorting, and pagination styles.
- [**Relations**](examples/relations.md) — Defining and using relationships.
- [**Transactions**](examples/transaction.md) — Atomic operations with MULTI/EXEC.

License
-------

[](#license)

Custom Fork-Only License. Please see the [LICENSE](LICENSE) file for more information.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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 ~3 days

Recently: every ~14 days

Total

22

Last Release

25d ago

Major Versions

0.1.0 → 1.0.02026-03-25

1.2.1 → 2.0.02026-04-03

PHP version history (2 changes)0.1.0PHP ^8.3

2.3.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/830be2b549214766fdf8e32fca9e60d97ead43099d11929f9e5728b592f40665?d=identicon)[masan27](/maintainers/masan27)

---

Top Contributors

[![masan27](https://avatars.githubusercontent.com/u/48290062?v=4)](https://github.com/masan27 "masan27 (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/masan27-laravel-redis-om/health.svg)

```
[![Health](https://phpackages.com/badges/masan27-laravel-redis-om/health.svg)](https://phpackages.com/packages/masan27-laravel-redis-om)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9742.3M121](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

721160.4k12](/packages/tallstackui-tallstackui)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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