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

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

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

tsslabs/toggle-bundle

最新稳定版本:0.1.0

Composer 安装命令:

composer require tsslabs/toggle-bundle

包简介

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

Add the bundle to your composer.json

$ composer require qandidate/toggle-bundle ~0.1

Add the bundle to your Kernel

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

Configuration

qandidate_toggle:
    persistence: in_memory|redis
    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

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),
    ));
}

Twig usage

If you use Twig you can also use the Twig function:

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

License

MIT, see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-09