定制 feature/feature 二次开发

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

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

feature/feature

Composer 安装命令:

composer require feature/feature

包简介

README 文档

README

A simple feature-flag API that can be used for toggling functionality.

Usage

$features = new FeatureManager;

$features->setUser(new User(['id' => 1]));

$features->enable('new_calendar', function(Feature\User $user) {
    return in_array($user->id, [1, 2, 5]);
});

if ($features->can('new_calendar')) {
    // ...
}

Enable features by adding toggles that inspect attributes of the current user. Toggles can be as simple as a closure or any instance that implements Toggle.

Storage

Feature toggles can be defined in three ways:

  • Direct PHP - as above,
  • a structured array,
  • or from a database.

Closures are supported by PHP and arrays in PHP (i.e. not from YAML etc.) Files and database require the toggle definitions to be pre-defined.

Structured array

$featureToggles = [
    // Feature name
    'view_calendar' => [
        // Each toggle with it's class name and constructor arguments
        ['name' => 'Feature\Toggles\IPWhitelist', 'params' => ['127.0.0.1']],

        // or a closure
        function(Feature\User $user) {
            return $user->id % 3 == 0;
        },

        // or a Toggle instance
        new Feature\Toggles\IPWhitelist(['192.168.0.1', '192.168.0.2']),
    ]
];

$features = new FeatureManager;
$storage = new Feature\Storage\Structured($features, $featureToggles);
$storage->load();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固