PHPackages                             namoshek/laravel-redis-sentinel - 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. namoshek/laravel-redis-sentinel

ActiveLibrary[Caching](/categories/caching)

namoshek/laravel-redis-sentinel
===============================

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

v1.3.0(1mo ago)38679.0k—5.1%23[1 issues](https://github.com/Namoshek/laravel-redis-sentinel/issues)MITPHPPHP ^8.2CI passing

Since Jul 18Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Namoshek/laravel-redis-sentinel)[ Packagist](https://packagist.org/packages/namoshek/laravel-redis-sentinel)[ Docs](https://github.com/Namoshek/laravel-redis-sentinel)[ RSS](/packages/namoshek-laravel-redis-sentinel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (19)Used By (0)

Laravel Redis Sentinel driver for `phpredis/phpredis` PHP extension
===================================================================

[](#laravel-redis-sentinel-driver-for-phpredisphpredis-php-extension)

[![Latest Version on Packagist](https://camo.githubusercontent.com/eb03ff95cba36ef9a216ef3058e115cc6b45f79116e46948b4a41a5f74fac63e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e616d6f7368656b2f6c61726176656c2d72656469732d73656e74696e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/namoshek/laravel-redis-sentinel)[![Total Downloads](https://camo.githubusercontent.com/d5181663bcce38c45bfdae0fd88c33445da49aaf3bffbc1544cc3cedc8a51b08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e616d6f7368656b2f6c61726176656c2d72656469732d73656e74696e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/namoshek/laravel-redis-sentinel)[![Tests](https://github.com/Namoshek/laravel-redis-sentinel/workflows/Tests/badge.svg)](https://github.com/Namoshek/laravel-redis-sentinel/actions?query=workflow%3ATests)[![Quality Gate Status](https://camo.githubusercontent.com/eb7320703afa3ad5ba13461501bfa1beb29659c5cf2584bc0b5d31ca3d5c374b/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e616d6f7368656b5f6c61726176656c2d72656469732d73656e74696e656c266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=namoshek_laravel-redis-sentinel)[![Maintainability Rating](https://camo.githubusercontent.com/ac541d1ea9ee474345f878c263d601ae52f1b5fb1371da8d02aed1681abdaf53/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e616d6f7368656b5f6c61726176656c2d72656469732d73656e74696e656c266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=namoshek_laravel-redis-sentinel)[![Reliability Rating](https://camo.githubusercontent.com/60ec0a7f3695e89d24737ed8f2b9e637a689ef346da997a0a8962ecd8f58e226/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e616d6f7368656b5f6c61726176656c2d72656469732d73656e74696e656c266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=namoshek_laravel-redis-sentinel)[![Security Rating](https://camo.githubusercontent.com/8ed1ea572e1ccf2e7ec7e0c6fd3bfcf0b573032c6538e8e420459fdd1a7f17c0/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e616d6f7368656b5f6c61726176656c2d72656469732d73656e74696e656c266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=namoshek_laravel-redis-sentinel)[![Vulnerabilities](https://camo.githubusercontent.com/ca68b5d80de906193a1864bb003bb8758833b0d423c7ff676b8c5f647dfcfc65/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e616d6f7368656b5f6c61726176656c2d72656469732d73656e74696e656c266d65747269633d76756c6e65726162696c6974696573)](https://sonarcloud.io/dashboard?id=namoshek_laravel-redis-sentinel)[![License](https://camo.githubusercontent.com/e5c8859b05b68be71d81aead92dccbe5f30afd6f2f74a9c2125f7ef8cf4588bd/68747470733a2f2f706f7365722e707567782e6f72672f6e616d6f7368656b2f6c61726176656c2d72656469732d73656e74696e656c2f6c6963656e7365)](https://packagist.org/packages/namoshek/laravel-redis-sentinel)

This package provides a Laravel Redis driver which allows connecting to a Redis master through a Redis Sentinel instance. The package is intended to be used in a Kubernetes environment or similar, where connecting to Redis Sentinels is possible through a load balancer.

This driver is an alternative to [`monospice/laravel-redis-sentinel-drivers`](https://github.com/monospice/laravel-redis-sentinel-drivers). The primary difference is that this driver supports the [`phpredis/phpredis` PHP extension](https://github.com/phpredis/phpredis)and has significantly simpler configuration, due to a simpler architecture. In detail this means that this package does not override the entire Redis subsystem of Laravel, it only adds an additional driver.

By default, Laravel supports the `predis` and `phpredis` drivers. This package adds a third `phpredis-sentinel` driver, which is an extension of the `phpredis` driver for Redis Sentinel. An extension for `predis` is currently not available and not necessary, since [`predis/predis`](https://github.com/predis/predis) already supports connecting to Redis through one or more Sentinels.

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

[](#installation)

You can install the package via composer:

```
composer require namoshek/laravel-redis-sentinel
```

The service provider which comes with the package is registered automatically.

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

[](#configuration)

The package requires no extra configuration and does therefore not provide an additional configuration file.

Usage
-----

[](#usage)

To use the Redis Sentinel driver, the `redis` section in `config/database.php` needs to be adjusted:

```
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis-sentinel'),

    'default' => [
        'sentinel_host' => env('REDIS_SENTINEL_HOST', '127.0.0.1'),
        'sentinel_port' => (int) env('REDIS_SENTINEL_PORT', 26379),
        'sentinel_service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'),
        'sentinel_timeout' => (float) env('REDIS_SENTINEL_TIMEOUT', 0),
        'sentinel_persistent' => env('REDIS_SENTINEL_PERSISTENT'),
        'sentinel_retry_interval' => (int) env('REDIS_SENTINEL_RETRY_INTERVAL', 0),
        'sentinel_read_timeout' => (float) env('REDIS_SENTINEL_READ_TIMEOUT', 0),
        'sentinel_username' => env('REDIS_SENTINEL_USERNAME'),
        'sentinel_password' => env('REDIS_SENTINEL_PASSWORD'),

        'connector_retry_attempts' => env('REDIS_CONNECTOR_RETRY_ATTEMPTS'),
        'connector_retry_delay' => env('REDIS_CONNECTOR_RETRY_DELAY'),

        'password' => env('REDIS_PASSWORD'),
        'database' => (int) env('REDIS_DB', 0),
    ]
]
```

Instead of changing `redis.client` in the configuration file directly, you can also set `REDIS_CLIENT=phpredis-sentinel` in the environment variables.

As you can see, there are also a few new `sentinel_*` options available for each Redis connection. Most of them work very similar to the normal Redis options, except that they are used for the connection to Redis Sentinel. Noteworthy is the `sentinel_service`, which represents the instance name of the monitored Redis master.

All other options are the same for the Redis Sentinel driver, except that `url` is not supported and `host` and `port` are ignored.

### SSL/TLS Support

[](#ssltls-support)

If you want to use SSL/TLS to connect to Redis Sentinel, you need to add an additional configuration option `sentinel_ssl` next to the other `sentinel_*` settings:

```
'sentinel_ssl' => [
    // ... SSL settings ...
],
```

Available SSL context options can be found in the [official PHP documentation](https://www.php.net/manual/en/context.ssl.php). Please note that SSL support for the Sentinel connection was added to the `phpredis` extension starting in version 6.1.

Also note that if your Redis Sentinel resolves SSL connections to Redis, you potentially need to add additional context options for your Redis connection:

```
'context' => [
    'stream' => [
        // ... SSL settings ...
    ]
],
'scheme' => 'tls',
```

A full configuration example using SSL for Redis Sentinel as well as Redis looks like this if authentication is also enabled (environment variables omitted for clarity):

```
'redis' => [
    'client' => 'phpredis-sentinel',

    'redis_with_tls' => [
        'sentinel_host' => 'tls://sentinel_host',
        'sentinel_port' => 26379,
        'sentinel_service' => 'mymaster',
        'sentinel_timeout' => 0,
        'sentinel_persistent' => false,
        'sentinel_retry_interval' => 0,
        'sentinel_read_timeout' => 0,
        'sentinel_username' => 'sentinel_username',
        'sentinel_password' => 'sentinel_password',
        'sentinel_ssl' => [
            'cafile' => '/path/to/sentinel_ca.crt',
        ],
        'context' => [
            'stream' => [
                'cafile' => '/path/to/redis_ca.crt',
            ],
        ],
        'scheme' => 'tls',
        'username' => 'redis_username',
        'password' => 'redis_password',
        'database' => 1,
    ]
]
```

The important parts are the `tls://` protocol in `sentinel_host` as well as the `tls` in `scheme`, plus the `sentinel_ssl` and `context.stream` options.

Because Redis Sentinel resolves Redis instances by IP and port, your Redis certificate needs to have the IP as SAN. Alternatively, you can set `verify_peer` and maybe also `verify_peer_name` to `false`.

### Multiple Sentinel instances

[](#multiple-sentinel-instances)

If your environment is composed of multiple Redis Sentinel instances, you can use the `sentinel_hosts` configuration instead of `sentinel_host` and `sentinel_port`.
`sentinel_hosts` is an array where each entry contains a `host` and a `port` key corresponding to a Sentinel instance.

#### Example configuration using multiple Redis Sentinel instances

[](#example-configuration-using-multiple-redis-sentinel-instances)

```
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis-sentinel'),

    'default' => [
        'sentinel_hosts' => [
            ['host' => '127.0.0.1', 'port' => 26379],
            ['host' => '127.0.0.1', 'port' => 26380],
            ['host' => '127.0.0.1', 'port' => 26381],
        ],
        'sentinel_service' => 'mymaster',
        'sentinel_timeout' => 0,
        'sentinel_persistent' => false,
        'sentinel_retry_interval' => 0,
        'sentinel_read_timeout' => 0,
        'sentinel_username' => 'sentinel_username',
        'sentinel_password' => 'sentinel_password',

        'password' => 'password',
        'database' => 1,
    ]
]
```

### How does it work?

[](#how-does-it-work)

An additional Laravel Redis driver is added (`phpredis-sentinel`), which resolves the currently declared master instance of a replication cluster as active Redis instance. Under the hood, this driver relies on the framework driver for [`phpredis/phpredis`](https://github.com/phpredis/phpredis), it only wraps the connection part of it and adds some error handling which forcefully reconnects in case of a failover.

Please be aware that this package does not manage load balancing between Sentinels (which is supposed to be done on an infrastructure level) and does also not load balance read/write calls to replica/master nodes. All traffic is sent to the currently reported master.

Developing
----------

[](#developing)

To run the tests locally, a Redis cluster needs to be running. The repository contains a script (thanks to [`monospice/laravel-redis-sentinel-drivers`](https://github.com/monospice/laravel-redis-sentinel-drivers)) which can be used to start one by running `sh start-redis-cluster.sh`. The script requires that Redis is installed on your machine. To install Redis on Ubuntu or Debian, you can use `sudo apt update && sudo apt install redis-server`. For other operating systems, please see [redis.io](https://redis.io/).

License
-------

[](#license)

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

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~106 days

Recently: every ~98 days

Total

17

Last Release

53d ago

Major Versions

v0.8.0 → v1.0.02025-07-18

PHP version history (3 changes)v0.1.0PHP ^8.0

v0.6.0PHP ^8.1

v1.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/38b0b9d27b847d8b05cde5b45dd0a4ae2bd6b798637e433c4c64cc865e1b8341?d=identicon)[Namoshek](/maintainers/Namoshek)

---

Top Contributors

[![Namoshek](https://avatars.githubusercontent.com/u/8877609?v=4)](https://github.com/Namoshek "Namoshek (54 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![florianJacques](https://avatars.githubusercontent.com/u/46104326?v=4)](https://github.com/florianJacques "florianJacques (1 commits)")[![igoooor](https://avatars.githubusercontent.com/u/1036285?v=4)](https://github.com/igoooor "igoooor (1 commits)")[![jeffreyzant](https://avatars.githubusercontent.com/u/913317?v=4)](https://github.com/jeffreyzant "jeffreyzant (1 commits)")[![miladev95](https://avatars.githubusercontent.com/u/35612406?v=4)](https://github.com/miladev95 "miladev95 (1 commits)")[![misakstvanu](https://avatars.githubusercontent.com/u/42741294?v=4)](https://github.com/misakstvanu "misakstvanu (1 commits)")[![OrangeJuiced](https://avatars.githubusercontent.com/u/22561290?v=4)](https://github.com/OrangeJuiced "OrangeJuiced (1 commits)")[![Alhubing](https://avatars.githubusercontent.com/u/16296784?v=4)](https://github.com/Alhubing "Alhubing (1 commits)")[![streamingsystems](https://avatars.githubusercontent.com/u/59889605?v=4)](https://github.com/streamingsystems "streamingsystems (1 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (1 commits)")

---

Tags

laravelredis

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

786.4k](/packages/yangusik-laravel-balanced-queue)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[encore/redis-manager

Redis manager for laravel

25243.1k](/packages/encore-redis-manager)[vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

43123.7k](/packages/vetruvet-laravel-phpredis)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k10](/packages/dragon-code-laravel-cache)[ginnerpeace/laravel-redis-lock

Simple redis distributed locks for Laravel.

15114.4k](/packages/ginnerpeace-laravel-redis-lock)

PHPackages © 2026

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