Download the PHP package antfroger/progressive-bundle without Composer
On this page you can find all versions of the php package antfroger/progressive-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download antfroger/progressive-bundle
More information about antfroger/progressive-bundle
Files in antfroger/progressive-bundle
Package progressive-bundle
Short Description The bundle to load Progressive, the library to progressively, quickly and simply enable new features
License MIT
Homepage https://github.com/antfroger/progressive-bundle
Informations about the package progressive-bundle
Progressive Bundle
Symfony integration for the feature-flag library Progressive
Installation
Install this bundle using Composer:
Configuration
1. Enable the Bundle
First, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
2. Configure the Bundle
Create the configuration file config/packages/af_progressive.yaml
.
The only required key is config
.
The key needs the path of the yaml file where you will configure the features of your application.
The minimal configuration looks like this:
But, you can also define under the context
key, variables that will be stored in the Contex object.
Then, you need to create the file that will contain your features.
It must contain at least the features
key:
But quickly, you can start adding many more features:
(every time you change this file, you may need to clear the cache og your application: php bin/console cache:clear
)
Look at Progressive documentation to know more about the features' configuration.
Usage
You can use Progressive in a controller using Symfony's autowiring:
Or in a template:
Rules
Built-in rules
Progressive comes with several built-in rules:
enabled: true|false
enabled
enables (or disables) the feature for everyone, everywhere, all the time.
Symfony specific rules
This bundle provides Symfony specific rules:
env: []
roles: []
users: []
env: []
env
enables (or disables) the feature depending on the app environment.
The value is meant to be an array of environment' names.
roles: []
roles
only enables (or disables) the feature for specific roles.
The value is meant to be an array of roles' names.
This example configuration enables the feature new-amazing-homepage
only for admins and dev.
users: []
users
is more fine-grained than roles
because, it allows you to enable a feature at a user level.
The value is meant to be an array of usernames.
This example configuration enables the feature secret-feature
only for the users antoine and ted.
Create your own rules
I'm sure that soon you will want to create your own rules to progressively enable features dependning on your application logic.
That's where custom rules come into play! (More information about custom rules on the Progressive doc)
To create your own rules and use them in your feature. yaml
file, you only need to create a class extending Progressive\Rule\RuleInterface
.
That's it!
Symfony autowiring takes care of the rest.
Let's say you want to display a chat in your contact page, but only in working hours (for instance between 9am and 7pm).
-
First, create the rule:
-
Now, you can use this new rule, in the
feature. yaml
file - You now have a feature using this new rule.
Let's use it in a controller or in a template:
Strategies
Thanks to strategies, you can combine the power of rules.
Let's say you want to enable your new feature one-click-payment
:
- for everyone in dev and preprod...
- but only for admins in prod...
- and two beta-testers (antoine and laurent).
This configuration will do the job:
Progressive comes with two built-in rules:
(but as they simply are nested rules, you can create your own strategies!)
unanimous: []
unanimous
is a strategy (a combinaison of several rules). It enables the feature if all the conditions are met / if all the rules are true.partial: []
patial
is also a strategy. It enables the feature if only one of the conditions is met / if at least one of the rules is true.
Commands
progressive:features
The command progressive:features
lists all the features configured in Progressive:
If you specify the name of the feature, its configuration will be displayed:
progressive:rules
The command progressive:rules
lists the rules provided by Progressive:
Web toolbar & profiler
In order to have an quick and easy access to the available features of your application - and see which ones are enabled for you - Symfony's web toolbar includes a tab with your defined features.
Symfony's profiler also includes a tab listing all the features of the application and their respective configuration.
All versions of progressive-bundle with dependencies
antfroger/progressive Version ^1.2
symfony/config Version ^5.4|^6.0
symfony/console Version ^5.4|^6.0
symfony/dependency-injection Version ^5.4|^6.0
symfony/http-kernel Version ^5.4|^6.0
symfony/security-core Version ^5.4|^6.0
symfony/var-dumper Version ^5.4|^6.0
symfony/yaml Version ^5.4|^6.0