Download the PHP package xepozz/feature-flag without Composer
On this page you can find all versions of the php package xepozz/feature-flag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xepozz/feature-flag
More information about xepozz/feature-flag
Files in xepozz/feature-flag
Package feature-flag
Short Description Feature-flag management system for Yii 3
License
Informations about the package feature-flag
Feature Flag
This is a simple library to enable/disable features based on a set of rules.
Installation
Configuration
Choose the driver you want to use. Currently, the library supports the following drivers:
- InMemory - stores data in memory. This driver is used by default.
- phpredis extension
InMemory
Configure the driver in the dependency injection container configuration file:
di.php
Or with params.php
:
Configuring the driver with
params.php
is only available for theInMemoryDriver
.
Redis
Configure the driver in the dependency injection container configuration file:
di.php
The driver uses a hash table functions to store and retrieve data. Read more about the hash table functions here.
Choose a driver
After you have chosen a driver, you need to configure the dependency injection container:
di.php
`
Usage
Pull \Xepozz\FeatureFlag\FlagStorageInterface
from the dependency injection container and use it:
isActive(string|int|BackedEnum $flag): bool
setFlag(string|int|BackedEnum $flag, bool $active): void
Be careful, in case of using not the
InMemoryDriver
, the flag will be stored permanently.In case of using the
InMemoryDriver
, the flag will be stored only for the current request. So you can switch the flag depending on the conditions in your code. For instance, you can enable the feature only for trusted IP addresses.
getAll(): array
Returns all flags as an associative array array<string, bool>
.
The only InMemoryDriver
supports returning BackendEnum
as a key, because it does not need to serialize the key.
The key is the flag name, the value is the flag state.
Testing
Redis
Redis driver requires phpredis extension and a running Redis server.
You can use the following command to start a Redis server in a Docker container:
Or use docker-compose:
Run tests:
Or
Looking for more modules?
- Unique ID - Allows you to track the unique user in the application.
- Request ID - A simple library to generate both unique request and response IDs for tracing purposes.
- AB - A simple library to enable A/B testing based on a set of rules.
- Shortcut - Sets of helper functions for rapid development of Yii 3 applications.