A feature flag lets you ship code to production switched off and enable it later for a chosen audience. Laravel Pennant is the official package for this and stores the decisions in the database.

bash
composer require laravel/pennant
php artisan vendor:publish --provider="Laravel\Pennant\PennantServiceProvider"
php artisan migrate

Defining features

A feature is a name plus a resolver, a closure that decides the value for a scope (by default, the logged-in user).

php
use App\Models\User;
use Illuminate\Support\Lottery;
use Laravel\Pennant\Feature;

public function boot(): void
{
    Feature::define('new-checkout', fn (User $user) => match (true) {
        $user->isInternalTeamMember() => true,
        $user->isHighTrafficCustomer() => false,
        default => Lottery::odds(1 / 10),
    });
}
How Pennant resolves a feature
How Pennant resolves a feature