worksome / feature-flags
A package to manage feature flags in your application
Fund package maintenance!
Requires
- php: ^8.4
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^13.0
- launchdarkly/server-sdk: ^6.4
- spatie/laravel-package-tools: ^1.93
Requires (Dev)
- canvural/larastan-strict-rules: ^3.0
- larastan/larastan: ^3.10
- nunomaduro/collision: ^8.6
- orchestra/testbench: ^11.3
- pestphp/pest: ^5.3
- pestphp/pest-plugin-laravel: ^5.0
- worksome/coding-style: ^7.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 09:38:17 UTC
README
A package to manage feature flags in your application. Currently supporting these providers:
Installation
You can install the package via composer:
composer require worksome/feature-flags
You can publish the config file with:
php artisan vendor:publish --tag="feature-flags-config"
See the config file for more information.
Creating Feature Flags
Feature flags should be registered using one or more enums containing your feature flags.
All feature flag enums must implement the Worksome\FeatureFlags\Contracts\FeatureFlagEnum contract.
For example, if you had a feature flag called flag-one, you could create an enum with the following:
namespace App\Enums; enum FeatureFlag: string implements \Worksome\FeatureFlags\Contracts\FeatureFlagEnum { case FlagOne = 'flag-one'; }
Reflag
The Reflag provider fetches all flags for a context in one request and keeps the result in memory for
cache_ttl seconds (default 15). Requests use connect_timeout 1.0 and timeout 2.0 seconds by default.
If Reflag fails or times out, the provider logs a warning and serves the last known result for that context,
or false when there is none, and does not call Reflag again for that context for failure_backoff seconds
(default 10). Set these under providers.reflag.options.
Use providers.reflag.context to send static attributes with every evaluation, for example
['sandbox' => 'acme']. They are merged into the other context, so one Reflag environment can target
several deployments. Booleans are sent as true/false and null values are dropped.
Usage in Blade
@feature(\App\Enums\FeatureFlag::FlagOne) This is content under a feature flag. @endfeature
Changelog
Please see the Releases for more information on what has changed recently.
Testing
We pride ourselves on a thorough test suite and strict static analysis. You can run all of our checks via a composer script:
composer test
To make it incredibly easy to contribute, we also provide a docker-compose file that will spin up a container with all the necessary dependencies installed. Assuming you have docker installed, just run:
docker-compose run --rm composer install # Only needed the first time docker-compose run --rm composer test # Run tests and static analysis
Support for XDebug is baked into the Docker image, you just need to configure the XDEBUG_MODE environment variable:
docker-compose run --rm -e XDEBUG_MODE=debug php
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.