Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Feature Toggle Bundle Laravel Package

bestit/feature-toggle-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

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');

Implementation Patterns

Debugging Flag Chains

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:

  1. Set FLAGCEPTION_DEBUG=true in .env.
  2. Use getEvaluationTrace() to debug complex flag chains (e.g., A/B tests, feature toggles).
  3. Disable debug mode in production (FLAGCEPTION_DEBUG=false).

Integration with Laravel Services

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);
}

Gotchas and Tips

Debug Mode Overhead

  • Pitfall: Enabling debug mode adds runtime overhead due to traceability. Fix: Disable in production (FLAGCEPTION_DEBUG=false).
  • Tip: Use dd($flag->getEvaluationTrace()) sparingly in staging.

Traceability Scope

  • The TraceableChainDecorator only works in debug mode. Ensure:
    if (config('flagception.debug')) {
        $trace = $flag->getEvaluationTrace(); // Works
    } else {
        $trace = null; // No trace available
    }
    

Configuration Quirks

  • The debug setting is not a runtime toggle—it requires a config reload or environment restart.
  • For dynamic toggling, use a custom decorator:
    app('flagception')->decorateWith(new class implements DecoratorInterface { ... });
    

Extension Points

  • Override 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;
        }
    }
    
  • Register via service provider:
    $this->app->make('flagception')->decorateWith(new CustomTraceDecorator());
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor