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 Bundle Laravel Package

adespresso/feature-bundle

Symfony bundle for feature releases and rollouts. Manage feature flags and enable new functionality for specific subsets of users. Includes API docs, documentation in Resources/doc, tests, and Apache 2.0 license.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony Integration: Designed for Symfony (Laravel is not natively supported), but core feature-flipping logic (e.g., user segmentation, toggle management) is language-agnostic. A Laravel-compatible wrapper could abstract Symfony dependencies (e.g., ContainerInterface, EventDispatcher).
  • Feature Flag Pattern: Aligns with modern feature flagging needs (A/B testing, gradual rollouts, environment-based toggles). Complements Laravel’s service container and middleware for request-level feature control.
  • Database Agnostic: Uses Doctrine DBAL (Symfony), but Laravel’s Eloquent or Query Builder could replace it with minimal effort.

Integration Feasibility

  • High: Core functionality (feature toggles, user targeting) is straightforward to port. Symfony’s EventDispatcher can be replaced with Laravel’s Events or Service Providers.
  • Middleware Hooks: Can integrate with Laravel’s middleware pipeline for request-level feature evaluation (e.g., FeatureMiddleware).
  • Configuration: YAML/XML configs (Symfony) → Laravel’s config/feature-flags.php or database-backed storage.

Technical Risk

  • Symfony Dependencies: Risk of breaking changes if relying on Symfony-specific components (e.g., ParameterBag). Mitigate via abstraction layer.
  • Laravel Ecosystem Gaps: No native Laravel support means manual setup (e.g., service binding, event listeners). Requires ~2–4 dev days to adapt.
  • Legacy Code: Last release in 2019—risk of deprecated Symfony versions. Audit compatibility with Symfony 5/6 before adoption.
  • Testing: Limited Laravel-specific tests; requires custom test suite for edge cases (e.g., caching, multi-tenant setups).

Key Questions

  1. Use Case Scope:
    • Is this for user segmentation (e.g., % rollout) or environment-based toggles (e.g., staging/prod)?
    • Do you need analytics (e.g., tracking impressions/conversions) or just toggle management?
  2. Storage Backend:
    • Prefer database (Eloquent), cache (Redis), or config files for feature flags?
  3. Performance:
    • Will feature evaluation be request-critical (needs caching) or batch-processed (e.g., cron jobs)?
  4. Extensibility:
    • Need custom conditions (e.g., geolocation, user attributes) beyond basic toggles?
  5. Alternatives:

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Replace Symfony ContainerInterface with Laravel’s Illuminate\Contracts\Container\Container.
    • Replace EventDispatcher with Laravel’s Events or Service Providers.
    • Use Eloquent or Query Builder instead of Doctrine DBAL for storage.
  • Middleware Integration:
    • Create a FeatureMiddleware to evaluate flags on each request (e.g., app/Http/Middleware/CheckFeatures.php).
    • Example:
      public function handle($request, Closure $next) {
          $feature = Feature::findByName($request->feature);
          if (!$feature->isEnabledFor($request->user())) {
              abort(403); // or redirect
          }
          return $next($request);
      }
      
  • Service Provider:
    • Bind the feature manager to Laravel’s container:
      $this->app->singleton(FeatureManager::class, function ($app) {
          return new FeatureManager(
              $app->make(FeatureRepository::class),
              $app->make(ConditionEvaluator::class)
          );
      });
      

Migration Path

  1. Phase 1: Proof of Concept (1–2 days)
    • Fork the repo, replace Symfony dependencies, and test basic toggle functionality.
    • Validate with a single feature flag in a non-critical route.
  2. Phase 2: Core Integration (3–5 days)
    • Implement middleware, service provider, and storage layer (DB/cache).
    • Add Laravel-specific tests (PHPUnit/Pest).
  3. Phase 3: Extensions (Optional, 1–2 weeks)
    • Add analytics (e.g., log impressions to feature_usage table).
    • Build a Laravel-specific admin UI (e.g., Spatie Laravel-Permission integration).

Compatibility

  • Laravel Versions: Tested with Laravel 8+ (Symfony 5+ compatibility).
  • PHP Versions: Requires PHP 7.4+ (aligns with Laravel 8+).
  • Database: Supports MySQL, PostgreSQL, SQLite (via Eloquent).
  • Caching: Optional Redis/Memcached integration for performance.

Sequencing

  1. Audit Dependencies: Replace Symfony components with Laravel equivalents.
  2. Storage Layer: Decide between DB (Eloquent) or cache (Redis).
  3. Middleware: Implement request-level feature checks.
  4. Testing: Write unit/integration tests for critical paths.
  5. Deployment: Roll out to a staging environment with monitoring.

Operational Impact

Maintenance

  • Pros:
    • Self-hosted: No vendor lock-in (unlike SaaS feature flags like LaunchDarkly).
    • Customizable: Extend conditions, storage, or UI without vendor constraints.
  • Cons:
    • No Active Maintenance: Last release in 2019; require internal upkeep.
    • Bug Fixes: Must patch Symfony compatibility issues internally.
  • Mitigation:
    • Fork the repo and treat as a private package.
    • Schedule quarterly dependency updates (e.g., Symfony 6+).

Support

  • Documentation: Limited to Symfony; require Laravel-specific guides.
  • Community: Small user base (14 stars); rely on internal knowledge sharing.
  • Troubleshooting:
    • Log feature evaluation decisions for debugging:
      Log::debug('Feature evaluated', ['feature' => $name, 'user' => $user->id, 'enabled' => $enabled]);
      
    • Use Laravel Horizon for async feature flag analytics.

Scaling

  • Performance:
    • Caching: Cache feature evaluations per user/route (e.g., Redis with TTL).
    • Database: Index feature_flags table on name and user_segment.
    • Load Testing: Simulate 10K RPS to validate middleware overhead.
  • Multi-Tenancy:
    • Extend UserSegment to support tenant IDs:
      class TenantAwareSegment implements UserSegmentInterface {
          public function matches(User $user): bool {
              return $user->tenantId === $this->tenantId;
          }
      }
      

Failure Modes

Failure Scenario Impact Mitigation
Database downtime Feature flags unavailable Fallback to config file cache
Middleware error 500 errors for all requests Circuit breaker (e.g., Spatie\CircuitBreaker)
Cache invalidation race Stale feature flags Use Redis with WATCH or database transactions
Symfony dependency breakage Integration fails Abstract behind interfaces; mock dependencies

Ramp-Up

  • Developer Onboarding:
    • 1-hour workshop: Walkthrough of feature flag lifecycle (define → enable → monitor).
    • Cheat Sheet: CLI commands for common tasks:
      # Enable a feature for 10% of users
      php artisan feature:enable analytics --percentage=10
      
      # List all active features for a user
      php artisan feature:list --user=1
      
  • Training Materials:
    • Record a Loom video demonstrating Laravel integration.
    • Document custom condition examples (e.g., "enable for users with premium plan").
  • Handoff to DevOps:
    • Define CI/CD checks for feature flag migrations.
    • Set up alerts for failed feature evaluations (e.g., Datadog/New Relic).
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui