- Can I use aubes/openfeature-bundle in Laravel even though it's a Symfony bundle?
- No, this bundle is specifically designed for Symfony 6.4+ applications. Laravel developers should explore alternatives like the OpenFeature PHP SDK directly or Laravel-specific packages like spatie/laravel-feature-flags. The bundle leverages Symfony’s DI container, attributes, and Twig integration, which aren’t natively available in Laravel.
- How do I configure aubes/openfeature-bundle to work with LaunchDarkly or ConfigCat?
- The bundle supports any OpenFeature-compliant provider. Install the provider SDK (e.g., `open-feature/launchdarkly-provider`), then configure it in `config/packages/open_feature.yaml` under the `providers` key. The bundle will automatically use it for flag evaluations. Built-in providers like InMemory or EnvVar are only for prototyping.
- What’s the difference between #[FeatureFlag] and #[FeatureGate] in controllers?
- #[FeatureFlag] injects a resolved boolean or typed value (e.g., `bool $darkMode`) into your method, while #[FeatureGate] acts as a guard—if the flag is off, Symfony throws a `FeatureDisabledException` before the method executes. Use #[FeatureGate] for access control (e.g., blocking routes) and #[FeatureFlag] for conditional logic.
- How do I pass user-specific attributes for flag targeting (e.g., A/B testing by user ID)?
- Implement `EvaluationContextProviderInterface` and bind it as a service. In your provider, return a `Context` object populated with attributes like `userId`, `country`, or `accountType`. The bundle will automatically use this context for all flag evaluations. Example: `return new Context(['userId' => $user->id]);`
- Will this bundle work in a Laravel + Symfony hybrid app (e.g., API Platform)?
- No, this bundle is not designed for Laravel or hybrid environments. It relies on Symfony’s kernel, DI container, and Twig templating system. For hybrid apps, consider using the OpenFeature PHP SDK directly or a Laravel-specific package, then share the `Client` instance between frameworks via a microservice or shared library.
- How do I test feature flags in CI/CD with mocked providers?
- Use the InMemory provider for testing. Configure it in `config/packages/open_feature.yaml` with test flags, then mock the `EvaluationContextProviderInterface` to simulate user attributes. Example: `new InMemoryProvider(['new_checkout' => true])`. For provider-specific testing, use the SDK’s mocking utilities (e.g., `MockClient` from `open-feature/sdk`).
- What happens if my remote provider (e.g., Flagd) fails during flag evaluation?
- The bundle includes a fallback mechanism: if the primary provider fails, it uses a secondary provider (configured in `open_feature.yaml`). If no fallback is set, it throws a `ProviderErrorException`. For production, design a circuit breaker or retry logic in a custom `Hook` implementation to handle transient failures gracefully.
- Can I use this bundle with PHP 8.1 or Symfony 6.3? The docs say 8.2+ is required.
- No, the bundle requires PHP 8.2+ and Symfony 6.4+ due to its use of attributes, typed properties, and modern PHP features. Downgrade support is unlikely, as the package is optimized for current Symfony versions. For older setups, consider the OpenFeature PHP SDK without the bundle or a legacy-compatible alternative.
- How do I debug feature flag evaluations in production? The Symfony Profiler shows flags, but I need more details.
- Enable the `OpenFeatureHook` for logging by implementing the `Hook` interface and binding it as a service. Log evaluations to a structured system (e.g., ELK, Datadog) via the `onEvaluate` method. For distributed systems, use OpenTelemetry or custom logging to trace flag resolutions across services. The Profiler panel is limited to local debugging.
- Are there performance concerns with dynamic EvaluationContext providers in high-traffic apps?
- Yes, expensive context calculations (e.g., database queries, external API calls) can introduce latency. Optimize by caching attributes (e.g., Redis) or pre-computing them in middleware. For high-throughput apps, avoid real-time context resolution—use static attributes or batch evaluations. Profile with `Xdebug` or Blackfire to identify bottlenecks.