Skip to content

Flags

The Laravel SDK ships a complete feature flags evaluator (FlowCatalyst\Flags\*) pinned to the shared FlowCatalyst conformance vectors, plus a drop-in driver (FlowCatalystPennantDriver) for laravel/pennant.

use FlowCatalyst\Facades\FlowCatalyst;
use FlowCatalyst\Flags\FlagDefinition;
$definitions = [
FlagDefinition::bool(
key: 'checkout.express',
defaultValue: false,
description: 'Enable one-click express checkout',
lifecycle: 'RELEASE',
governance: 'CLIENT_MANAGED',
exposeToClient: true,
),
FlagDefinition::enum(
key: 'routing.engine',
allowedValues: ['standard', 'fast'],
defaultValue: 'standard',
description: 'Route calculation engine',
lifecycle: 'EXPERIMENT',
governance: 'OPERATORS_ONLY',
),
];
$flags = FlowCatalyst::featureFlags('orders', $definitions);
$flags->syncDefinitions();

FeatureFlagsClient caches snapshots in Laravel’s configured cache store and uses conditional If-None-Match requests (304 Not Modified) to keep reloads cheap across PHP workers.

use FlowCatalyst\Flags\EvalContext;
$evalCtx = new EvalContext(
client: $tenant->code,
principal: $user->principal_id,
tier: 'CLIENT',
roles: $user->roles,
attrs: ['site' => $siteCode],
);
if ($flags->bool($evalCtx, 'checkout.express')) {
// ...
}
$engine = $flags->enum($evalCtx, 'routing.engine');
$exposed = $flags->evaluateClientExposed($evalCtx); // ['revision' => int, 'flags' => [...]]

If the platform cannot be reached during a refresh, the last cached snapshot stays active; on cold start without a cached snapshot, declared code defaults are returned.

Install laravel/pennant and register FlowCatalystPennantDriver in a service provider:

use FlowCatalyst\Client\FlowCatalystClient;
use FlowCatalyst\Flags\EvalContext;
use FlowCatalyst\Flags\FlowCatalystPennantDriver;
use Laravel\Pennant\Feature;
Feature::extend('flowcatalyst', function ($app) use ($definitions) {
$flags = $app->make(FlowCatalystClient::class)
->featureFlags('orders', $definitions);
return new FlowCatalystPennantDriver(
client: $flags,
scopeResolver: fn (mixed $scope): EvalContext => new EvalContext(
client: $scope?->tenantCode ?? '_platform',
principal: $scope?->principalId,
roles: $scope?->roles ?? [],
),
);
});

Set PENNANT_STORE=flowcatalyst (or add a flowcatalyst store in config/pennant.php) and use standard Pennant calls:

if (Feature::for($tenantScope)->active('checkout.express')) {
// ...
}
$engine = Feature::for($tenantScope)->value('routing.engine');

Writes through Feature::for($scope)->activate(...) / deactivate(...) forward to the platform’s delegated client-override endpoint (honouring CLIENT_MANAGED and operator lock rules).

$flags->setClientOverride('checkout.express', 'acme', true, $actingPrincipalId);
$flags->deleteClientOverride('checkout.express', 'acme', $actingPrincipalId);