Laravel Pennant is a package created by the Laravel team that will arrive with https://laravel-news.com/laravel-10 provides Feature Flags for your applications. Feature flags enable you to incrementally roll out new application features with confidence, A/B test new interface designs, compliment a trunk-based development strategy, and much more.
Creating a new feature is a simple process of defining it with your AppServiceProvider like so: public function boot(): void { Feature::define('beta-testers', fn (User $user) => match (true) { $user->isBetaTester() => true, default => false, }); }
However, you can also use a class-based approach to your features: class BetaTesters { public function resolve(User $user): mixed { return match (true) { $user->isBetaTester() => true, default => false, }; }}
class PodcastController { public function __construct( private readonly RedirectAction $action, ) {} public function index(Request $request): Response { return Feature::when(BetaTester::class, fn () => $this->action->handle('v2'), fn () => $this->action->handle('v1'), ); }}