Download the PHP package digital-gravy/feature-flag without Composer
On this page you can find all versions of the php package digital-gravy/feature-flag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download digital-gravy/feature-flag
More information about digital-gravy/feature-flag
Files in digital-gravy/feature-flag
Package feature-flag
Short Description Feature Flag for WordPress
License GPL-3.0-or-later
Homepage https://github.com/Digital-Gravy/feature-flag
Informations about the package feature-flag
PHP Feature Flag Manager
A flexible PHP library for managing feature flags with multiple storage backends.
Installation
You can install the library via Composer:
Features
- Simple on/off feature flag management
- Multiple storage backends:
- JSON file
- PHP Constants
- Array-based storage
- Type-safe implementation
- Extensible storage interface
- Exception handling for invalid flags
Usage
Basic Usage
JSON File Storage
Example flags.json:
PHP Constants Storage
Multiple Sources
The FeatureFlagStore
constructor accepts an array of flags from different storage backends.
When multiple sources are provided, the flags are merged together, and the last source overrides the previous ones.
Flag Rules
- Flag keys must contain only alphanumeric characters, underscores, and dashes
- Flag values must be either 'on' or 'off'
- Flag keys are case-insensitive and stored in lowercase
Custom Storage Backend
You can implement your own storage backend by implementing the FlagStorageInterface:
Error Handling
The library includes several exception types:
Invalid_Flag_Key
: Thrown when a flag key contains invalid charactersInvalid_Flag_Value
: Thrown when a flag value is not 'on' or 'off'Flag_Key_Not_Found
: Thrown when attempting to check a non-existent flagNot_A_Flag
: Thrown when invalid flag types are providedFileNotFoundException
: Thrown when the JSON file does not existFileNotReadableException
: Thrown when the JSON file exists but is not readable
License
GPLv3 - see LICENSE file for details