bestit/laravel-flagception

Laravel 驱动,用于 bestit/flagception-sdk

dev-master 2018-06-29 11:17 UTC

This package is auto-updated.

Last update: 2024-08-29 04:37:17 UTC


README

为 Laravel 提供特性切换。为 flagception/flagception-sdk 提供 Laravel 服务提供者。

安装和设置

通过 composer 安装

composer require bestit/laravel-flagception

该包将自动注册自己。

如果你使用的是 Laravel 5.5 或更高版本,这个包将被自动发现。对于早期版本,你需要在 app.php 中注册服务提供者

// config/app.php

'providers' => [
    // ...
    BestIt\LaravelFlagception\FlagceptionServiceProvider::class,
];

该包的核心是配置。要发布它,请运行

php artisan vendor:publish --provider="BestIt\LaravelFlagception\FlagceptionServiceProvider"

基本用法

在你的配置文件中定义一个特性

// config/flagception.php

return [
    //...
    'features' => [
        'feature_123' => [
            'active' => false,
        ],
    ],
];

在你需要的地方注入 FeatureManager

class WelcomeController extends Controller
{
    public function index(FeatureManager $featureManager)
    {
        if ($featureManager->isActive('feature_123')) {
            //do something
        }
        //...
    }
}