Feature Flags
Feature Flags is a symfony bundle that integrates feature flags into your application.
Installation
composer require 21torr/feature-flags
Defining Feature Flags
In the root of your project, create a .features.yaml
file and define your feature flags there:
feature: true
some-other: false
login: on
something: off
You can use true
, false
, on
and off
as possible values.
Usage
PHP / Symfony
Fetch the FeatureFlags
service:
<?php
public function myAction (FeatureFlags $flags) : Response
{
if (!$flags->hasFeature("login"))
{
throw $this->createNotFoundException("Login disabled.");
}
return $this->render(...);
}
Twig
In twig, use the has_feature()
twig function:
{%- if has_feature("login") -%}
<a href="{{ path("login") }}">Login</a>
{%- endif -%}