lwiesel/feature-checker-bundle

Enable and disable functional features in Symfony2 applications.

v1.1.0 2015-03-03 14:35 UTC

This package is not auto-updated.

Last update: 2024-11-23 17:32:49 UTC


README

Packagist Software License Build Status Coverage Status Quality Score HHVM Total Downloads

SensioLabsInsight

Define features, and check if they are activated or not in your Symfony2 application.

Usage

Define a feature configuration in your config.yml.

# app/config/config.yml

feature_checker:
    features:
        feature1: true
        feature2: false
        feature3:
            feature31: true
            feature32: true

Then use the features names in controller annotations. Only the allowed features will execute the action.

<?php
// src/AppBundle/Controller/DefaultController.php

namespace AppBundle\Controller;

use LWI\FeatureCheckerBundle\Annotations\MustHaveFeature;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    /**
     * @MustHaveFeature("feature1")
     */
    public function indexAction()
    {
        return $this->render('default/index.html.twig');
    }
}

Sub-features can be checked with this notation:

    /**
     * @MustHaveFeature("feature1")
     * @MustHaveFeature("feature3.feature31")
     */
    public function secondAction()
    {
        return $this->render('default/second.html.twig');
    }

You can also test whole feature sets. A feature set is considered enabled when all sub-features -at any sub-level- is enabled.

    /**
     * @MustHaveFeature("feature3")
     */
    public function thirdAction()
    {
        return $this->render('default/third.html.twig');
    }
}

Installation

Please see Full documentation for details.

Testing

$ bin/phpspec run

Contributing

Please see CONTRIBUTING for details.

Changelog

Please see CHANGELOG for details.

Security

If you discover any security related issues, please email wiesel.laurent@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.