PHPackages                             yiisoft/yii2-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. [Framework](/categories/framework)
4. /
5. yiisoft/yii2-redis

ActiveYii2-extension[Framework](/categories/framework)

yiisoft/yii2-redis
==================

Redis Cache, Session and ActiveRecord for the Yii framework

2.1.0(4mo ago)48011.7M—2.1%183[26 issues](https://github.com/yiisoft/yii2-redis/issues)[3 PRs](https://github.com/yiisoft/yii2-redis/pulls)20BSD-3-ClausePHPPHP ^7.3 || ^8.0CI passing

Since Nov 30Pushed 1mo ago43 watchersCompare

[ Source](https://github.com/yiisoft/yii2-redis)[ Packagist](https://packagist.org/packages/yiisoft/yii2-redis)[ GitHub Sponsors](https://github.com/yiisoft)[ Fund](https://opencollective.com/yiisoft)[ RSS](/packages/yiisoft-yii2-redis/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (27)Used By (20)Security (2)

    ![Yii Framework](https://camo.githubusercontent.com/cc75562bca6e54e98046e4fb187ef8d96c997a8f31c6f4d2f6ed0c816413b47a/68747470733a2f2f7777772e7969696672616d65776f726b2e636f6d2f696d6167652f7969695f6c6f676f5f6c696768742e737667)

Redis Cache, Session and ActiveRecord for Yii 2
===============================================

[](#redis-cache-session-and-activerecord-for-yii-2)

This extension provides [redis](https://redis.io/) key-value store support for the [Yii framework 2.0](https://www.yiiframework.com). It provides `Cache`, `Mutex`, and `Session` handlers, as well as an `ActiveRecord` implementation that allows you to store and query structured data in a familiar way.

[![Latest Stable Version](https://camo.githubusercontent.com/20d65c87ea3a64f45ca8b81c323a22d566a9cf9a242d522258891dba490bbc3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796969736f66742f796969322d72656469732e7376673f7374796c653d666f722d7468652d6261646765266c6162656c3d537461626c65266c6f676f3d7061636b6167697374)](https://packagist.org/packages/yiisoft/yii2-redis)[![Total Downloads](https://camo.githubusercontent.com/e7c0015aa77a7aa2862f6ea9f248db8c73962519b86853b087301e899ef88547/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796969736f66742f796969322d72656469732e7376673f7374796c653d666f722d7468652d6261646765266c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/yiisoft/yii2-redis)[![build](https://camo.githubusercontent.com/998b9c69102cd49240edf5a83ed1a93075738e253eab7a94c2169e8899ee260f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f796969736f66742f796969322d72656469732f6275696c642e796d6c3f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6162656c3d4275696c64)](https://github.com/yiisoft/yii2-redis/actions?query=workflow%3Abuild)[![codecov](https://camo.githubusercontent.com/b6024663e3c174a4b739107140d40704ba83af83151d7644440991f425e87d3d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f796969736f66742f796969322d72656469732e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6465636f76266c6f676f436f6c6f723d7768697465266c6162656c3d436f6465636f76)](https://codecov.io/gh/yiisoft/yii2-redis)[![Static Analysis](https://camo.githubusercontent.com/84b2a13b91c8d3dc1c17f42382a7c09d420e7d22a1fb340e21c3878b67df3f5e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f796969736f66742f796969322d72656469732f7374617469632e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d537461746963)](https://github.com/yiisoft/yii2-redis/actions/workflows/static.yml)

Requirements
------------

[](#requirements)

Redis version 2.6.12 or later is required for all components to work properly.

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

[](#installation)

Important

- The minimum required [PHP](https://www.php.net/) version is PHP `7.4`.
- It works best with PHP `8`.

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yiisoft/yii2-redis:"~2.1.0"
```

or add

```
"yiisoft/yii2-redis": "~2.1.0"
```

to the require section of your composer.json.

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

[](#configuration)

To use this extension, you have to configure the Connection class in your application configuration:

```
return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];
```

**SSL configuration** example:

```
return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6380,
            'database' => 0,
            'useSSL' => true,
            // Use contextOptions for more control over the connection (https://www.php.net/manual/en/context.php), not usually needed
            'contextOptions' => [
                'ssl' => [
                    'local_cert' => '/path/to/local/certificate',
                    'local_pk' => '/path/to/local/private_key',
                ],
            ],
        ],
    ],
];
```

**Configuring The Connection Scheme**

By default, Redis will use the tcp scheme when connecting to your Redis server; however, you may use TLS / SSL encryption by specifying a scheme configuration option in your application configuration:

```
return [
    //....
    'components' => [
        'redis' => [
            //....
            'scheme' => 'tls'
        ]
    ]
];
```

Documentation
-------------

[](#documentation)

- [the guide](docs/guide/README.md)

Support the project
-------------------

[](#support-the-project)

[![Open Collective](https://camo.githubusercontent.com/ad8d82ae4dbf7869403317d29b3ab412509ad638d6b58d8855ec18853b5ab5ba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f70656e253230436f6c6c6563746976652d73706f6e736f722d3765616466313f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e253230636f6c6c656374697665266c6f676f436f6c6f723d376561646631266c6162656c436f6c6f723d353535353535)](https://opencollective.com/yiisoft)

Follow updates
--------------

[](#follow-updates)

[![Official website](https://camo.githubusercontent.com/289983c1dde520aac09b2e2c1456588e33a6551e5353146255ef287aef12483e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d796969)](https://www.yiiframework.com/)[![Follow on X](https://camo.githubusercontent.com/332c1b1e043dfb940b95825f7863dc473f6924ddacdd6738cbbbba08f49e1862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d466f6c6c6f772532306f6e253230582d3144413146322e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d78266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://x.com/yiiframework)[![Telegram](https://camo.githubusercontent.com/011b161ebda90a674c45717c4bf9147979afb1ec6900246ef70ed6ba2bfc55b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d6a6f696e2d3144413146323f7374796c653d666f722d7468652d6261646765266c6f676f3d74656c656772616d)](https://t.me/yii_framework_in_english)[![Slack](https://camo.githubusercontent.com/73a139b0b78939a369c6b99ada6184607d59e6d0c0c216d44c4012a1b3cd06ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d6a6f696e2d3144413146323f7374796c653d666f722d7468652d6261646765266c6f676f3d736c61636b)](https://yiiframework.com/go/slack)

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/680c8d62ba2d5a71d7099b6e81114fb0b22d99086c121fd178e1149afc669d44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4253442d2d332d2d436c617573652d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e736f75726365696e6974696174697665266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](LICENSE.md)

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance81

Actively maintained with recent releases

Popularity69

Solid adoption and visibility

Community56

Growing community involvement

Maturity78

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~302 days

Total

26

Last Release

144d ago

Major Versions

2.0.20 → 22.x-dev2025-07-08

PHP version history (2 changes)22.x-devPHP &gt;=8.1

2.1.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/261a6249c6f605f3956a2fae40fbb813f6b2e1e6f2bf806180c851a965426e54?d=identicon)[cebe](/maintainers/cebe)

![](https://www.gravatar.com/avatar/fc29e4e7068a00fe9b9db37b8aadda1db6020adcacef810461e47b99c2b150e6?d=identicon)[samdark](/maintainers/samdark)

![](https://www.gravatar.com/avatar/23416c58e0dce33a8369451a4ca0e28666373594027debc10184b37ade6a926b?d=identicon)[qiangxue](/maintainers/qiangxue)

---

Top Contributors

[![qiangxue](https://avatars.githubusercontent.com/u/993322?v=4)](https://github.com/qiangxue "qiangxue (1909 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (804 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (691 commits)")[![klimov-paul](https://avatars.githubusercontent.com/u/1482054?v=4)](https://github.com/klimov-paul "klimov-paul (322 commits)")[![creocoder](https://avatars.githubusercontent.com/u/896494?v=4)](https://github.com/creocoder "creocoder (152 commits)")[![resurtm](https://avatars.githubusercontent.com/u/100198?v=4)](https://github.com/resurtm "resurtm (123 commits)")[![tonydspaniard](https://avatars.githubusercontent.com/u/566016?v=4)](https://github.com/tonydspaniard "tonydspaniard (95 commits)")[![Ragazzo](https://avatars.githubusercontent.com/u/1748844?v=4)](https://github.com/Ragazzo "Ragazzo (75 commits)")[![lucianobaraglia](https://avatars.githubusercontent.com/u/374554?v=4)](https://github.com/lucianobaraglia "lucianobaraglia (45 commits)")[![suralc](https://avatars.githubusercontent.com/u/730039?v=4)](https://github.com/suralc "suralc (42 commits)")[![pmoust](https://avatars.githubusercontent.com/u/2493339?v=4)](https://github.com/pmoust "pmoust (36 commits)")[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (26 commits)")[![slavcodev](https://avatars.githubusercontent.com/u/757721?v=4)](https://github.com/slavcodev "slavcodev (20 commits)")[![LarryUllman](https://avatars.githubusercontent.com/u/1674823?v=4)](https://github.com/LarryUllman "LarryUllman (18 commits)")[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (16 commits)")[![crtlib](https://avatars.githubusercontent.com/u/4428231?v=4)](https://github.com/crtlib "crtlib (12 commits)")[![mohorev](https://avatars.githubusercontent.com/u/4974062?v=4)](https://github.com/mohorev "mohorev (12 commits)")[![bwoester](https://avatars.githubusercontent.com/u/309565?v=4)](https://github.com/bwoester "bwoester (12 commits)")[![tarasio](https://avatars.githubusercontent.com/u/1010578?v=4)](https://github.com/tarasio "tarasio (12 commits)")[![gevik](https://avatars.githubusercontent.com/u/434535?v=4)](https://github.com/gevik "gevik (10 commits)")

---

Tags

hacktoberfestredisyiiyii2rediscachesessionyii2active-record

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yiisoft-yii2-redis/health.svg)

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

###  Alternatives

[yiisoft/yii2-elasticsearch

Elasticsearch integration and ActiveRecord for the Yii framework

4371.9M15](/packages/yiisoft-yii2-elasticsearch)[yiisoft/yii2-mongodb

MongoDB extension for the Yii framework

3312.1M45](/packages/yiisoft-yii2-mongodb)[yiisoft/yii2-sphinx

Sphinx full text search engine extension for the Yii framework

180997.7k5](/packages/yiisoft-yii2-sphinx)[arogachev/yii2-sortable

Sortable ActiveRecord for Yii 2 framework

1637.0k4](/packages/arogachev-yii2-sortable)[yiisoft/cache-redis

Yii Caching Library - Redis Handler

1012.9k](/packages/yiisoft-cache-redis)

PHPackages © 2026

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