- Can I use adespresso/feature-bundle directly in Laravel without Symfony?
- No, this bundle is Symfony-native, but you can adapt it for Laravel by replacing Symfony dependencies (e.g., ContainerInterface, EventDispatcher) with Laravel equivalents. Expect ~2–4 dev days to create a wrapper layer for core functionality like feature toggles and user segmentation.
- What Laravel versions does this package support?
- The package aligns with Symfony 5/6, so it’s compatible with Laravel 8+ (PHP 7.4+). Test thoroughly with your Laravel version, as the original bundle hasn’t been updated since 2019. Symfony 6+ may require additional abstraction for newer Laravel features.
- How do I store feature flags—database, cache, or config files?
- Replace Doctrine DBAL (Symfony) with Laravel’s Eloquent or Query Builder for database storage. For caching, integrate Redis/Memcached via Laravel’s cache system. Config files (YAML/XML) can be migrated to Laravel’s `config/feature-flags.php` for simplicity.
- Does this support gradual rollouts (e.g., 10% of users) or just on/off toggles?
- Yes, the bundle supports targeted rollouts via user segmentation (e.g., percentage-based, user attributes). The core logic for conditional feature evaluation can be adapted to Laravel’s middleware or service containers for request-level control.
- Are there Laravel-specific alternatives with better maintenance?
- Yes, consider `spatie/laravel-feature-flags` for a Laravel-native solution with active maintenance, built-in caching, and database support. It’s more integrated with Laravel’s ecosystem (e.g., Eloquent, Events) and avoids Symfony dependencies entirely.
- How do I integrate feature flags into Laravel’s middleware pipeline?
- Create a `FeatureMiddleware` in `app/Http/Middleware/` to evaluate flags per request. Example: Check if a feature is enabled for the current user, then abort or redirect if disabled. This approach works seamlessly with Laravel’s middleware stack.
- Can I track feature usage (e.g., impressions/conversions) with this bundle?
- The original bundle lacks analytics, but you can extend it by logging impressions to a `feature_usage` table or integrating with Laravel’s logging/observers. Add a custom condition evaluator to trigger analytics on flag evaluation.
- What’s the performance impact of evaluating feature flags on every request?
- For request-critical apps, cache flag evaluations using Laravel’s cache system (e.g., Redis). The bundle’s core logic is lightweight, but Symfony’s EventDispatcher (if used) may need replacement with Laravel’s Events for better performance.
- How do I configure feature flags for multi-tenant applications?
- Extend the bundle’s condition evaluator to include tenant IDs (e.g., via middleware or user context). Store tenant-specific flags in a separate table or use Laravel’s context-based caching to isolate tenant data.
- Is there official Laravel documentation or a migration guide for this package?
- No official Laravel docs exist, but the Symfony bundle’s `Resources/doc/` provides core concepts. For Laravel adaptation, follow the integration approach in the TPM assessment: replace dependencies, implement middleware, and test with PHPUnit/Pest. Community forks may offer partial guides.