Download the PHP package check24/feature-flag-bundle without Composer

On this page you can find all versions of the php package check24/feature-flag-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package feature-flag-bundle

FeatureFlagBundle

Easily toggle features in your Symfony app. Built-in providers are .env, cookies and userAgent. But you can extend the system with own providers (f.e. for A/B testing).

Install

Install the package via composer:

Usage

Accessing feature flag states

Limit access to controller actions

You can use the IsActive annotation to let the action only be accessible if the given feature is active. Otherwise a 403 is thrown:

As a dependency injection

To access the state of a feature inside a service, you can inject the FeatureFlagInterface

In Twig

Use the twig function is_active to check if a feature is enabled:

Configuring feature flag providers

In your config/packages/shopping_feature_flag.yaml configuration, you can configure the built-in providers to define, which feature flag (key) should be active, when the user inputs on of the values:

You can enable/disable some of the built in providers.

Toggling features

Feature flags can be toggled by the configured providers. If at least one of the providers reports the feature as active, it is active.

.env

Toggle a feature environment wide in your .env file. You could f.e. disable the feature in your productive .env file but enable it in your staging .env file.

(Prefix "FEATUREFLAG_" and uppercase feature flag name)

Cookie

Activate a feature only for yourself by setting a cookie in your browser, f.e. in Chrome with F12 -> Application -> Cookies

(Prefix "featureFlag_" and feature flag name)

If you haven't specified a specific value in the config for the feature flag, any value will activate the feature. Use the config to make the features more secure.

User-Agent

Activate a feature only for yourself by setting a custom User-Agent in your browser (f.e. with the Chrome plugin "User-Agent Switcher").

Configure in the shopping_feature_flag.yaml, what parts of the User-Agent activates what feature:

-> When using a User-Agent containing the string foobar/chrome, the Feature "foobar" is active. This way it is possible to activate multiple features with one User-Agent, which contains all needed keys for the features while preserving the browser/device detection of the website.

Create own provider

If you want to activate features in a custom way, you want to write your own provider.

In this example we create a time-based provider, so the specific feature "morningShow" is only activated between 8 and 10 a.m. .

First create a provider class, implement the FeatureFlagInterface with the isActive() method. This method should return true if the given feature is active. Otherwise return false.

Remember: A feature is active if any provider reports it as being active, so returning false doesn't deactivate the feature completely, but instead looks into all other providers if they report it as active.

Next, tag the service with the featureFlag.provider tag:

And you are done. The feature "morningShow" will now always be active between 8 and 10 a.m.

You can use this feature to realise an A/B testing, so you activate the feature only for a specific group of users.

Env Var Processor

To use a feature flag's value within a bundle's configuration you may use the feature_flag env var processor. This is especially useful when used in conjunction with custom feature flag providers, f.e. when you're loading flags from a database via doctrine.

The above snippet will set the enable_baz config of ExampleBundle to the value of a feature flag called foo_bar. You can use the same technique when you'd like to register a specific feature flag as container parameter:

$container->getParameter('maintenance_mode') will now contain either true or false, depending on whether the feature flag is active or not.


All versions of feature-flag-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
symfony/config Version >=4.3 <6.0
symfony/dependency-injection Version >=4.3 <6.0
doctrine/annotations Version ^1.6
symfony/http-kernel Version >= 4.3 <6.0
twig/twig Version >=2.5 <4.0
symfony/framework-bundle Version >=4.3 <6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package check24/feature-flag-bundle contains the following files

Loading the files please wait ....