rasuvaeff / yii3-feature-flags-redis
Redis-backed feature flag provider for Yii3 applications
Package info
github.com/rasuvaeff/yii3-feature-flags-redis
pkg:composer/rasuvaeff/yii3-feature-flags-redis
v1.0.0
2026-06-05 14:31 UTC
Requires
- php: ^8.3
- predis/predis: ^2.0
- rasuvaeff/yii3-feature-flags: ^1.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.51
- friendsofphp/php-cs-fixer: ^3.95
- infection/infection: ^0.29
- maglnet/composer-require-checker: ^4.17
- phpunit/phpunit: ^11.5
- psalm/plugin-phpunit: ^0.19
- rector/rector: ^2.4
- vimeo/psalm: ^6.16
This package is auto-updated.
Last update: 2026-06-05 14:39:19 UTC
README
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.0predis/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
InvalidFlagPayloadExceptioninstead of silently enabling features. Core validation errors are wrapped, so callers only need to catchInvalidFlagPayloadException. - 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.