PHPackages                             barbery/laravel-phpredis - 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. barbery/laravel-phpredis

ActiveLibrary

barbery/laravel-phpredis
========================

phpredis library for laravel

v5.2.x-dev(10y ago)72.6k2BSDPHPPHP &gt;=5.6.0

Since Apr 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Barbery/laravel-phpredis)[ Packagist](https://packagist.org/packages/barbery/laravel-phpredis)[ Docs](https://github.com/Barbery/laravel-phpredis)[ RSS](/packages/barbery-laravel-phpredis/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

laravel-phpredis
================

[](#laravel-phpredis)

this is the library provide phpredis support in the laravel framework, clearly it support redis cluster too.

feature
-------

[](#feature)

1. this library implement redis driver in Cache and Session, and Queue, you can easy to use it.
2. implement redis pipeline just like the laravel document introduce
3. you can customize your serilize and unserilize function
4. you can customize your cache expired time default unit

requirements
------------

[](#requirements)

- PHP &gt;= 5.6.x
- [PhpRedis](https://github.com/phpredis/phpredis)
- Laravel &gt;= 5.2.x

install
-------

[](#install)

You can install it by composer, just execute below command

### for laravel &gt;= 5.4

[](#for-laravel--54)

Since laravel 5.4, laravel already support phpredis dirver. So, you don't need to use this library. [More info](https://laravel.com/docs/5.4/redis)

### for laravel &gt;= 5.3

[](#for-laravel--53)

```
composer require barbery/laravel-phpredis:dev-master
```

### for laravel &gt;= 5.2

[](#for-laravel--52)

```
composer require barbery/laravel-phpredis:v5.2.x-dev
```

config
------

[](#config)

If you want to completely use phpredis instead of predis... You should add below config to your config/app.php file:

```
'providers' => [
        // ...
        // YOUR OTHER PROVIDERS SETTING
        // ...
        // And you should commend those system's provider as below
        // Illuminate\Redis\RedisServiceProvider::class,

        // add this to your providers
        Barbery\Providers\RedisServiceProvider::class,
]

aliases => [
        // you must rename the Redis Key name, because it's conflict with the \Redis class provide by phpredis
        // may be you can rename it to MyRedis, So, you can use it like that:
        // MyRedis::get('key'); MyRedis::set('key', 'value'); MyRedis::pipeline(function($pipe){YOUR_CODE});
        'MyRedis' => Illuminate\Support\Facades\Redis::class,
]
```

```
// add config to `config/database.php`
'redis' => [
        // if this true, will enable redis cluster mode
        'cluster' => env('REDIS_CLUSTER', false),

        // defualt config is for single redis mode not cluster
        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            // can take one of the values:
            // Redis::SERIALIZER_NONE, 'none',
            // Redis::SERIALIZER_PHP, 'php',
            // Redis::SERIALIZER_IGBINARY, 'igbinary'
            'serializer' => env('REDIS_SERIALIZER', Redis::SERIALIZER_PHP),
        ],

        // this is for redis cluster mode
        'clusterConfig' => [
            // cluster options
            'options' => [
                'failover' => env('REDIS_CLUSTER_FAILOVER', RedisCluster::FAILOVER_ERROR),
                'read_timeout' => env('REDIS_CLUSTER_READ_TIMEOUT', 3),
                'timeout' => env('REDIS_CLUSTER_TIMEOUT', 3),
                'persistent' => env('REDIS_CLUSTER_PERSISTENT', false),
            ],
            // put your cluster master node here
            [
                'host' => env('REDIS_HOST_1'),
                'port' => env('REDIS_PORT_1'),
            ],
            [
                'host' => env('REDIS_HOST_2'),
                'port' => env('REDIS_PORT_2'),
            ],
            [
                'host' => env('REDIS_HOST_3'),
                'port' => env('REDIS_PORT_3'),
            ],
        ],
    ],
```

Advance config
--------------

[](#advance-config)

The default unit in laravel is minutes, if you want to change it, you can add config in your `app/cache.php`

```
'stores' => [
        // YOUR OTHER SETTING
        // ...

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            // add this config to change the default unit, it can be 'second','minute','hour'
            'defaultUnit' => 'second',
            // if you don't set encodeFunc and decodeFunc,
            // default to use php serialize and unserialize to encode/decode value
            // below setting show you how to change it to use json_encode/json_decode to encode/decode value
            'encodeFunc' => function($value){return json_encode($value);},
            'decodeFunc' => function($value){return json_decode($value, true);},
        ],
    ],
```

Issue
-----

[](#issue)

Because Laravel 5.3.x use Lua script to migrate the queue job, and the redis cluster is not support. So if you use Laravel 5.3.x with redis cluster mode, then do not use the RedisQueue.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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

Unknown

Total

1

Last Release

3685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81bcdd6d6dc2416f0306a1406a2ce3cc4d61dd3890f1bd1b8396160ab76100cf?d=identicon)[barbery](/maintainers/barbery)

---

Top Contributors

[![Barbery](https://avatars.githubusercontent.com/u/2239529?v=4)](https://github.com/Barbery "Barbery (26 commits)")[![lagunovsky](https://avatars.githubusercontent.com/u/6282615?v=4)](https://github.com/lagunovsky "lagunovsky (2 commits)")

---

Tags

laravelphpredislaravel-phpredisredisServiceProviderredisStore

### Embed Badge

![Health badge](/badges/barbery-laravel-phpredis/health.svg)

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

###  Alternatives

[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[longman/laravel-lodash

Add more functional to Laravel

9792.9k](/packages/longman-laravel-lodash)[hemp/presenter

Easy Model Presenters in Laravel

247592.6k1](/packages/hemp-presenter)[vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

43123.7k](/packages/vetruvet-laravel-phpredis)[slowlyo/owl-admin

基于 laravel、amis 开发的后台框架~

61214.2k26](/packages/slowlyo-owl-admin)

PHPackages © 2026

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