This guide assumes you have already installed and registered the bundle (see the README Quick start) and added a minimal open_feature.yaml with a few flags.
Two PHP attributes cover most use cases: #[FeatureGate] to guard access, #[FeatureFlag] to inject resolved values.
use Aubes\OpenFeatureBundle\Attribute\FeatureFlag;
use Aubes\OpenFeatureBundle\Attribute\FeatureGate;
use Symfony\Component\HttpFoundation\Response;
class CheckoutController
{
#[FeatureGate('new_checkout')]
public function checkout(
#[FeatureFlag('dark_mode')] bool $darkMode,
#[FeatureFlag('max_items')] int $maxItems,
): Response {
// $darkMode and $maxItems are resolved from the active provider
}
}What happens here:
#[FeatureGate('new_checkout')]: the method is unreachable whennew_checkoutevaluates tofalse. A 403 is thrown (configurable, see Configuration).#[FeatureFlag('dark_mode')] bool $darkMode: the flag is resolved as a boolean based on the parameter type hint.#[FeatureFlag('max_items')] int $maxItems: same, resolved as an integer viagetIntegerValue().
Type dispatch is automatic for bool, string, int, float, and array. See #[FeatureFlag] for the full table.
- Configuration reference for the full config tree
- Providers to connect a real feature flag backend (Flagd, ConfigCat, Unleash...)
- Features for all integrations: attributes, Twig, EvaluationContext, Hooks
- Profiler & Debug to inspect evaluated flags during development