PHPackages                             coding-socks/reloquent - 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. coding-socks/reloquent

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

coding-socks/reloquent
======================

Object mapping, and more, for Redis and PHP.

v0.1.0(4y ago)14MITPHPPHP ^7.4 || ^8.0

Since Jan 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/coding-socks/reloquent)[ Packagist](https://packagist.org/packages/coding-socks/reloquent)[ RSS](/packages/coding-socks-reloquent/feed)WikiDiscussions main Synced 1mo ago

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

Reloquent
=========

[](#reloquent)

Redis + Eloquent = Reloquent

Introduction
------------

[](#introduction)

Reloquent is an **experimental object-relational mapper** (ORM) that makes it enjoyable to interact with Redis. In addition to managing Redis hashes, Reloquent models allow you to search records with RediSearch.

This library is heavily inspired by [Redis OM](https://redis.com/blog/introducing-redis-om-client-libraries/).

Define a model:

```
use CodingSocks\Reloquent\Model;

class Movie extends Model
{
    protected $schema = [
        'title' => ['type' => 'string', 'textSearch' => true],
        'year' => ['type' => 'number'],
        'directors' => ['type' => 'array'],
    ];
}
```

Create a new model and save it:

```
$movie = new Movie()
$movie->title = "Alice in Wonderland";
$movie->year = 1951;
$movie->directors = ['Clyde Geronimi', 'Wilfred Jackson', 'Hamilton Luske'];
$movie->save()
```

Search for models:

```
Movie::query()
    ->where('title', 'matches', ['Alice', 'Wonderland'])
    ->where('year', ' [

        // [...]

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'data_structure' => 'hash',
        ],

        // [...]

    ],

    // [...]
```

Everything else will come from your redis configuration.

Create, Fetch, Update, and Delete a model
-----------------------------------------

[](#create-fetch-update-and-delete-a-model)

A model only needs a schema when RediSearch is available to manage indexes. When only HASH or JSON data types are managed then it's not necessary.

```
