PHPackages                             bilaliqbalr/laravel-redis - 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. [Caching](/categories/caching)
4. /
5. bilaliqbalr/laravel-redis

ActiveLibrary[Caching](/categories/caching)

bilaliqbalr/laravel-redis
=========================

This package will provide redis based laravel auth driver

1.0.5(4y ago)131587[1 issues](https://github.com/bilaliqbalr/laravel-redis/issues)MITPHPPHP ^7.3|^8.0

Since Oct 4Pushed 4y ago2 watchersCompare

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

READMEChangelogDependencies (10)Versions (7)Used By (0)

Laravel Redis
=============

[](#laravel-redis)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0e1dd05c4ec8f9b462836dfbc57f39180d09d88c630ad5b516b27165dc89ab85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696c616c697162616c722f6c61726176656c2d72656469732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilaliqbalr/laravel-redis)[![GitHub Tests Action Status](https://camo.githubusercontent.com/108be2605543d37b271f2ce8e743eb3e0c9fde305153cb47a8f2e0a97f1e8451/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62696c616c697162616c722f6c61726176656c2d72656469732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/bilaliqbalr/laravel-redis/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/85baaadf617d6cff3522782c4aaf7c537c717f526cddedea3e66621e9c895d44/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62696c616c697162616c722f6c61726176656c2d72656469732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/bilaliqbalr/laravel-redis/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7aa6296033b23076caf68362e35c0255d0e5b167091461e3b5e9c256ab1a6b11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696c616c697162616c722f6c61726176656c2d72656469732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilaliqbalr/laravel-redis)

---

As name suggested this package will let you use Redis as a database instead of using it just for caching purpose. It works almost the same way as using Laravel Eloquent but with some differences. With this package forget the pain of naming keys and managing them in Redis. Some of the core features are as follows:

1. No need to create migration files, just provide required columns in `$fillable` and this package will take care of the rest
2. Perform CRUD operations just like doing them in Laravel
3. Search model functionality
4. Managing relations
5. Laravel auth backed by Redis

---

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

[](#installation)

You can install the package via composer:

```
composer require bilaliqbalr/laravel-redis
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Bilaliqbalr\LaravelRedis\LaravelRedisServiceProvider" --tag="laravel-redis-config"
```

Usage
-----

[](#usage)

To create new redis model run this command

```
php artisan redis:model Post
```

### Prefixes

[](#prefixes)

Prefixes are used to maintain the key structure for specific model, this package creates prefixes by default using Model name, and in case you want to change it you can do this as follow

```
public function prefix() : string
{
    return 'post';
}
```

### Change connection

[](#change-connection)

You can change redis connection in model as well

```
protected $connection = "redis";
```

### Searching model by specific column

[](#searching-model-by-specific-column)

In case you need to get model based on specific field, you can do this by using `$searchBy`where you just need to specify column names in the list and this package will store a new key value pair where key is `{model}:column:%s` (`%s` is the column value) where value will be the model id to fetch required model.

```
protected $searchBy = [
    'title',
];
```

To get model based on that title field, you can do this as follows

```
$post = Post::searchByTitle("iphone");

# This works the same way as we do while using eloquent
# Post::where('title', 'iphone')->first();
```

Other operations like create, update and delete works same as in Laravel

```
# Creating new post
$post = Post::create([
    'user_id' => 1,
    'title' => 'iPhone 13 release',
    'description' => 'Lorem ipsum dolor',
]);

# Getting data is a bit different
$post = Post::get(1); // 1 is the model id

# Get post by title
$post = Post::searchByTitle('iphone');

# Update post info
$post->update([
    'description' => 'Lorem ipsum dolor sat amet'
]);

# Delete post
$post->delete();
// or
Post::destroy(1);
```

### Get all records keys

[](#get-all-records-keys)

```
// return list of all records keys from redis
$post->getAllKeys();

// Return list of all records ids
$post->getAllKeys(true);
```

### Add new searchBy fields

[](#add-new-searchby-fields)

If you need to add new searchBy field after you have records in your redis database, then you need to run this command to make old records searchable with new column

```
php artisan refresh:search_by App\\Redis\\Post
```

### Managing model relations

[](#managing-model-relations)

With this package you can even create relation between models but that is not like the one in Laravel, as redis is not a relational database.

```
# User.php

# Adding post relation
public function posts() {
    return $this->relation(new \App\Models\Redis\Post);
}
```

```
# Creating post under user
# Below will automatically add user_id field in the Post model.
$post = $user->posts()->create([
    'title' => 'iPhone 13 pro',
    'description' => 'Lorem ipsum dolor',
]);

# Getting all user posts
$posts = $user->post()->get();
$paginatedPosts = $user->post()->paginate();
```

### Auth

[](#auth)

```
# In config/auth.php
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'redis',  // use provider name as in laravel-redis.php config file
    ],
],
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Bilal Iqbal](https://github.com/bilaliqbalr)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~61 days

Total

6

Last Release

1475d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d0dfb1a0d25407949ba190728383205d47bb0bfb4316d9151a436fa17b5ec81?d=identicon)[bilaliqbalr](/maintainers/bilaliqbalr)

---

Top Contributors

[![bilaliqbalr](https://avatars.githubusercontent.com/u/4525426?v=4)](https://github.com/bilaliqbalr "bilaliqbalr (37 commits)")

---

Tags

laravellaravel-authphpredislaravellaravel-redisbilaliqbalr

###  Code Quality

TestsPest

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M162](/packages/spatie-laravel-health)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M46](/packages/spatie-laravel-pdf)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M189](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

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