rasuvaeff/yii3-feature-flags-redis

Redis-backed feature flag provider for Yii3 applications

Maintainers

Package info

github.com/rasuvaeff/yii3-feature-flags-redis

pkg:composer/rasuvaeff/yii3-feature-flags-redis

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-05 14:31 UTC

This package is auto-updated.

Last update: 2026-06-05 14:39:19 UTC


README

Stable Version Total Downloads Build Static Analysis Coverage PHP License

Redis-backed feature flag provider for Yii3 applications. Implements the FlagProvider interface from rasuvaeff/yii3-feature-flags and reads flag configuration from a Redis HASH via HGETALL.

Using an AI coding assistant? llms.txt contains a compact API reference you can ingest in your prompt context.

Requirements

  • PHP 8.3+
  • rasuvaeff/yii3-feature-flags ^1.0
  • predis/predis ^2.0

Installation

composer require rasuvaeff/yii3-feature-flags-redis

Redis storage format

One Redis HASH per flag set:

  • Key: {prefix}:{version}:flags
  • Field: flag name
  • Value: JSON payload
{
    "enabled": true,
    "salt": "",
    "rollout": 100,
    "killSwitch": false,
    "environments": ["production"]
}

Usage

use Rasuvaeff\Yii3FeatureFlags\FeatureFlags;
use Rasuvaeff\Yii3FeatureFlagsRedis\RedisFlagProvider;

$provider = new RedisFlagProvider(
    client: $predis,             // Predis\ClientInterface
    prefix: 'feature-flags',     // optional, default 'feature-flags'
    version: 'v1',               // optional, default 'v1'
);

$featureFlags = new FeatureFlags(provider: $provider);

if ($featureFlags->isEnabled('new-checkout')) {
    // new checkout flow
}

API reference

Class Description
RedisFlagProvider Reads all flags from Redis HASH via HGETALL
InvalidFlagPayloadException Thrown when a JSON payload is invalid

Security

  • Kill switch, rollout hash logic, and environment targeting remain in the core package — Redis is only a configuration source.
  • Invalid JSON, wrong types, out-of-range rollout, or invalid flag names throw InvalidFlagPayloadException instead of silently enabling features. Core validation errors are wrapped, so callers only need to catch InvalidFlagPayloadException.
  • Read-only: no write operations are performed.

Examples

See examples/ for runnable scripts.

Development

composer build          # full gate: validate + normalize + cs + psalm + test
composer cs:fix         # auto-fix code style
composer psalm          # static analysis
composer test           # run tests

License

BSD-3-Clause. See LICENSE.md.