Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pennant Laravel Package

laravel/pennant

Laravel Pennant is a simple, lightweight feature flag library for Laravel. Manage, evaluate, and roll out features safely across environments with an easy API and first-party integration, backed by official Laravel documentation.

View on GitHub
Deep Wiki
Context7

A simple, lightweight library for managing feature flags.

Frequently asked questions about Pennant
How do I install Laravel Pennant in my Laravel project?
Run `composer require laravel/pennant` to install the package. Then publish the migration and configuration files with `php artisan pennant:install`, and run the migrations using `php artisan migrate`. The package is ready to use after these steps.
What Laravel versions does Pennant support?
Pennant officially supports Laravel 11 and 12. Laravel 10 is supported with backported patches, but older versions (e.g., 9.x) are not recommended. Always check the [Laravel documentation](https://laravel.com/docs/pennant) for the latest compatibility details.
Can I use Pennant for A/B testing in my Laravel app?
Yes, Pennant supports A/B testing by defining flags with different variations (e.g., `feature_x_variant_a` and `feature_x_variant_b`). You can scope flags to users or sessions and evaluate them dynamically in your Blade templates or middleware.
How do I integrate Pennant with Laravel Blade templates?
Use the `@feature` and `@featureany` Blade directives to conditionally render content. For example, `@feature('new-dashboard')` will only render the enclosed content if the flag is enabled. This works seamlessly with Livewire and Inertia.js.
Does Pennant support Redis or other cache backends for flags?
Yes, Pennant includes a cache driver that works with Redis, Memcached, or Laravel’s default cache. Configure the driver in `config/pennant.php` and set `driver` to `cache`. Flags will automatically sync with your cache backend.
How do I restrict access to routes based on feature flags?
Use the `EnsureFeaturesAreActive` middleware to gate routes. Add it to your `routes/web.php` or `app/Http/Kernel.php` under the `$routeMiddleware` array. For example, `Route::middleware(['web', 'features:new-dashboard'])->group(...);`.
Can I test feature flags in my Laravel tests (Pest/PHPUnit)?
Yes, Pennant provides a fake helper for testing. Use `Pennant::fake()` to simulate flag states in your tests. For example, `Pennant::fake(['new-dashboard' => true])` will override the flag during testing without affecting production.
What’s the best way to manage feature flags in production?
For production, use the database driver (default) for persistence and the cache driver for performance. Enable `cache_flush` in the driver config to ensure flags update in real-time. Avoid frequent flag changes during high-traffic periods to minimize cache invalidation.
How do I migrate from another feature flag package (e.g., Spatie Feature Flags) to Pennant?
Export your existing flags from the old package (e.g., as JSON or database dumps) and import them into Pennant’s database table. Use `Pennant::create()` or bulk operations like `Pennant::setMany()` to populate flags. Test thoroughly in staging before switching in production.
Does Pennant support multi-region or distributed deployments?
For multi-region setups, use a shared cache like Redis or DynamoDB as your flag storage. Configure the cache driver in `config/pennant.php` and ensure all regions point to the same cache backend. This ensures consistent flag evaluation across deployments.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai