laravel/pennant
Laravel Pennant is a simple, lightweight feature flag library for Laravel. Define and evaluate feature flags to safely roll out, test, and target functionality in your app. Official docs available on the Laravel website.
before callbacks), making it adaptable for complex use cases like A/B testing or gradual rollouts.EnsureFeaturesAreActive middleware enables route/endpoint-level feature gating without manual checks.feature() helper is namespaced).@feature and @featureany directives for templating, reducing boilerplate.flushCache() hooks, but custom drivers must implement this correctly.if (config('flags.new_feature'))) will need refactoring to use Pennant’s API.user_id) or complex (e.g., user_role AND geo_region)? Will dynamic scopes (e.g., based on request data) be needed?before hooks support automatic rollback logic?Pennant::fake()), but integration tests may need adjustments.EnsureFeaturesAreActive integrates with Laravel’s middleware pipeline.FeatureUpdated events trigger observables (e.g., logging, analytics).pennant:purge, pennant:load for CLI management.feature() helper or middleware.// Before (config-based)
if (config('features.new_ui')) { ... }
// After (Pennant)
if (feature('new_ui')->isActive()) { ... }
php artisan pennant:install to create the flags table.EnsureFeaturesAreActive to routes requiring flags.@if(config('features.x')) with @feature('x').Pennant::fake()).feature() helper is namespaced to avoid collisions.composer require laravel/pennant.php artisan vendor:publish --provider="Laravel\Pennant\PennantServiceProvider".config/pennant.php.php artisan migrate.php artisan pennant:load --features=flag1,flag2.PennantSeeder to populate flags on php artisan db:seed.feature('flag')->isActive().Route::middleware(['web', 'pennant'])->group(...).Pennant::fake().new_ui flag gates the dashboard").FeatureUpdated events).pennant:purge) cleans up unused flags.config/pennant.php (e.g., default driver, cache TTL)..env or scoped flags (e.g., feature('staging_only')->for('env', 'staging')).php artisan cache:clear), database connection, and migrations.feature('x')->for('user_id', auth()->id())).DB::enableQueryLog() to debug slow flag queries.How can I help you explore Laravel packages today?