承接 nemishkor/toggle-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nemishkor/toggle-bundle

Composer 安装命令:

composer require nemishkor/toggle-bundle

包简介

This Bundle provides the integration with qandidate/toggle. It provides the services and configuration you need to implement feature toggles in your Symfony application.

README 文档

README

This Bundle provides the integration with our toggle library. It provides the services and configuration you need to implement feature toggles in your application.

Build Status

About

Read the our blog post series about this repository at:

Installation

Using Symfony Flex

The easiest way to install and configure the QandidateToggleBundle with Symfony is by using Symfony Flex.

Make sure you have Symfony Flex installed:

$ composer require symfony/flex ^1.0
$ composer config extra.symfony.allow-contrib true

Install the bundle:

$ composer require qandidate/toggle-bundle ^1.0

Symfony Flex will automatically register and configure the bundle.

Manually

Add the bundle to your composer.json

$ composer require qandidate/toggle-bundle ^1.0

Add the bundle to your Kernel:

$bundles = array(
    // ..
    new Symfony\Bundle\SecurityBundle\SecurityBundle(),
    new Symfony\Bundle\TwigBundle\TwigBundle(),
    new Qandidate\Bundle\ToggleBundle\QandidateToggleBundle(),
);

Configuration

qandidate_toggle:
    persistence: in_memory|redis|factory|config
    context_factory: null|your.context_factory.service.id
    redis_namespace: toggle_%kernel.environment% # default, only required when persistence = redis
    redis_client: null|your.redis_client.service.id # only required when persistence = redis
    collection_factory: # only required when persistence = factory
        service_id: your.collection_factory.service.id
        method: create

Sample Configuration for Symfony

qandidate_toggle:
    persistence: config
    toggles:
      always-active-feature:
        name: always-active-feature
        status: always-active
      inactive-feature:
        name: inactive-feature
        status: inactive
        conditions: 
      conditionally-active:
        name: conditionally-active
        status: conditionally-active
        conditions:
         - name: operator-condition
           key: user_id
           operator:
               name: greater-than
               value: 42

Example usage

Usage can vary on your application. This example uses the supplied UserContextFactory, but you probably need to create your own factory.

<!-- services.xml -->

<service id="acme.controller" class="Acme\Controller">
    <argument type="service" id="qandidate.toggle.manager" />
    <argument type="service" id="qandidate.toggle.user_context_factory" />
</service>
// Acme\Controller

public function __construct(
    /* ArticleRepository, Templating, ..*/ 
    ToggleManager $manager, 
    ContextFactory $contextFactory
) {
    // ..
    $this->manager = $manager;
    $this->context = $contextFactory->createContext();
}

// ..

public function articleAction(Request $request)
{
    $this->article = $this->repository->findBySlug($request->request->get('slug'));

    return $this->templating->render('article.html.twig', array(
        'article'        => $article,
        'enableComments' => $this->manager->active('comments', $this->context),
    ));
}

You can find a working example using the Symfony MicroKernelTrait in the Resources/doc/example directory.

Annotation Usage

You can also use the @Toggle annotation on a controller. When the toggle isn't active a 404 exception is thrown.

use Qandidate\Bundle\ToggleBundle\Annotations\Toggle;

/**
 * @Toggle("cool-feature")
 */
class FooController
{

    /**
     * @Toggle("another-cool-feature")
     */
    public function barAction()
    {
    }

    public function bazAction()
    {
    }
}

Twig usage

If you use Twig you can also use the function:

{% if feature_is_active('comments') %}
    {# Awesome comments #}
{% endif %}

Or the Twig test:

{% if 'comments' is active feature %}
    {# Awesome comments #}
{% endif %}

Both are registered in the ToggleTwigExtension.

Data collector

With the data collector you have a overview about all toggles. In the toolbar you see all conditions and the current status.

In the panel you have two lists:

  • You can see all keys and there current values.
  • Then you can see all configured toggles, there conditions and if they are active.

Testing

To run PHPUnit tests:

$ ./vendor/bin/phpunit

License

MIT, see LICENSE.

nemishkor/toggle-bundle 适用场景与选型建议

nemishkor/toggle-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nemishkor/toggle-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nemishkor/toggle-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 nemishkor/toggle-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-20