定制 rasuvaeff/yii3-feature-flags-redis 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rasuvaeff/yii3-feature-flags-redis

最新稳定版本:v1.1.0

Composer 安装命令:

composer require rasuvaeff/yii3-feature-flags-redis

包简介

Redis-backed feature flag provider for Yii3 applications

README 文档

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

Requires rasuvaeff/yii3-feature-flags ^2.0. With Yii3 config-plugin this package binds FlagProvider automatically — do not also bind FlagProvider in your application or another backend, or yiisoft/config reports a Duplicate key error.

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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-06-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固