Download the PHP package e0ipso/feature_flags without Composer
On this page you can find all versions of the php package e0ipso/feature_flags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download e0ipso/feature_flags
More information about e0ipso/feature_flags
Files in e0ipso/feature_flags
Package feature_flags
Short Description A module for feature flags in Drupal.
License GPL-2.0-or-later
Informations about the package feature_flags
Feature Flags
Client-side feature flags that work with Varnish, CDN, and BigPipe. Resolve variants in JavaScript, not PHP.
What This Module Does
Create feature flags with multiple variants. Configure percentage rollouts and conditions. Everything resolves client-side so your page cache stays fast.
Perfect for high-traffic sites using aggressive caching (Varnish, CDN, BigPipe).
Pairs beautifully with ab_tests for A/B testing with metrics.
See It In Action
Video Walkthrough
👆 30-second walkthrough showing the complete setup and resolution process
Step-by-Step with Screenshots
1. Enable Settings (Debug + Persistence)
Enable debug mode to see resolution in console. Enable persistence to cache decisions in localStorage.
2. Create Your Feature Flag
Define basic info: label, machine name, description.
3. Add Variants (Minimum 2, JSON Values)
Each variant has a label and JSON value. CodeMirror editor included.
Example: "Heads, Tails, or Edge" coin flip
- Heads:
{"result": "heads", "color": "#FFD700"} - Tails:
{"result": "tails", "color": "#C0C0C0"} - Edge:
{"result": "edge", "color": "#FF6B6B"}(rare!)
4. Configure Percentage Rollout
48% Heads, 48% Tails, 4% Edge. Percentages must sum to 100%.
5. Resolve in JavaScript
Console Output:
Debug mode shows the full resolution process. Result is cached in localStorage for consistency.
Installation
Core Concepts
Variants
Each flag has 2 or more variants with JSON values. Think of variants as the possible outcomes.
Algorithms
Algorithms decide which variant a user gets. The Percentage Rollout algorithm distributes users by percentage (e.g., 25% variant A, 75% variant B).
How to create a custom algorithm
1. **PHP Plugin**: `src/Plugin/DecisionAlgorithm/MyAlgorithm.php` - Extends `DecisionAlgorithmPluginBase` - Defines admin configuration form - Returns JavaScript settings 2. **JavaScript Class**: `js/algorithm/MyAlgorithm.js` - Extends `BaseAlgorithm` - Implements `decide(context)` method - Returns selected variant 3. **Library**: Add to `feature_flags.libraries.yml`Conditions
Conditions filter when an algorithm applies. Target specific users, or custom context.
Built-in conditions:
- User ID: Match specific user IDs
How to provide custom context
Listen to the `featureFlags:provideContext` event: Then create conditions that evaluate your custom context:Use With ab_tests for A/B Testing
The feature_flags module controls rollout. The ab_tests module tracks metrics.
Example: Progressive checkout rollout with conversion tracking
When to use each:
| Need | Use | Why |
|---|---|---|
| Gradual rollout (10% → 50% → 100%) | feature_flags |
Percentage control |
| Track metrics & conversions | ab_tests |
Analytics |
| Experiment + rollout | Both together | Best of both worlds |
Requirements
- Drupal 10.3+ or 11.x
- PHP 8.2+
- Modern browser with ES6 support
Testing
Test Commands
Documentation
- docs/diagrams.md - Mermaid diagram source code
License
GPL v2 or later