bestit/feature-toggle-bundle
Install the package via Composer:
composer require bestit/flagception-bundle
Publish the configuration (if needed):
php artisan vendor:publish --provider="BestIT\FlagceptionBundle\FlagceptionBundle" --tag="config"
Enable debug mode in config/flagception.php to leverage the new TraceableChainDecorator for debugging flag evaluation chains:
'debug' => env('FLAGCEPTION_DEBUG', false),
Use the bundle's services in your Laravel application (e.g., flag evaluation):
$flag = app('flagception')->evaluate('feature.x');
Leverage the TraceableChainDecorator in debug mode to inspect flag evaluation logic:
if (config('flagception.debug')) {
$flag = app('flagception')->evaluate('feature.x'); // Decorator adds traceability
dd($flag->getEvaluationTrace()); // Inspect the chain
}
Workflow:
FLAGCEPTION_DEBUG=true in .env.getEvaluationTrace() to debug complex flag chains (e.g., A/B tests, feature toggles).FLAGCEPTION_DEBUG=false).Extend existing flag logic (e.g., middleware, policies):
// app/Http/Middleware/FeatureFlagMiddleware.php
public function handle($request, Closure $next) {
if (app('flagception')->evaluate('feature.admin_dashboard')) {
return $next($request);
}
abort(403);
}
FLAGCEPTION_DEBUG=false).dd($flag->getEvaluationTrace()) sparingly in staging.TraceableChainDecorator only works in debug mode. Ensure:
if (config('flagception.debug')) {
$trace = $flag->getEvaluationTrace(); // Works
} else {
$trace = null; // No trace available
}
debug setting is not a runtime toggle—it requires a config reload or environment restart.app('flagception')->decorateWith(new class implements DecoratorInterface { ... });
TraceableChainDecorator to customize trace output:
// src/Decorators/CustomTraceDecorator.php
class CustomTraceDecorator implements DecoratorInterface {
public function evaluate(Flag $flag) {
$trace = $flag->getEvaluationTrace();
// Modify trace logic here
return $flag;
}
}
$this->app->make('flagception')->decorateWith(new CustomTraceDecorator());
How can I help you explore Laravel packages today?