在当前版本和canary版本之间切换功能。

dev-main 2020-12-13 14:53 UTC

This package is auto-updated.

Last update: 2024-09-15 00:14:55 UTC


README

在当前版本和canary版本之间切换功能。

示例

<?php

require_once __DIR__ . '/vendor/autoload.php';

use RiversideHotel\Canary\FeatureToggle;
use RiversideHotel\Canary\Partitioning\Strategy;

$config = [
    [
        'name' => 'new feature',
        'enabled'  => true,
        'strategy' => [
            'type' => Strategy::TYPE_PERCENTAGE,
            'args' => [10], // rolls out this features to 10% users
        ],
    ],
];

$toggle = FeatureToggle::createWithConfiguration($config);

// If the feature is not explicitly defined,
// this value will be returned.
$default = false;

// context is the scalar value used to check if the feature is available.
// The value can be a user ID, content ID, or something else.
$context = 1;

if ($toggle->isAvailable('new feature', $default, $context)) {
    echo 'new feature is available';
} else {
    echo 'new feature is unavailable';
}

用法

工作进展中(请暂时查看测试案例

许可证

canary遵循MIT许可证