creativitykills / filament-pennant
Manage Feature Flags using Laravel Pennant from Filament.
Fund package maintenance!
CreativityKills
Requires
- php: ^8.4
- filament/filament: ^3.3
- illuminate/contracts: ^10.0||^11.0||^12.0
- laravel/pennant: ^1.17
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
This package is auto-updated.
Last update: 2025-06-06 12:03:07 UTC
README
This plugin is heavily inspired by this plugin. There are several improvements including but not limited to:
- Support for scoped feature flags
- Support for Features in custom directories
- and more...
Installation
You can install the package via composer:
composer require creativitykills/filament-pennant
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-pennant-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-pennant-config"
Usage
This package is exclusively for class based features.
You'll have to register the plugin in your panel provider.
public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentPennantPlugin::make() ->authorize(fn () => auth()->user()->can('view.features')) // ...additional configuration available ->setNavigationGroup(__('Developer')) ->setNavigationLabel(__('Feature Segments')) ->setModelLabel(__('Feature Segments')), ]); }
You don't have to call
Feature::discover()
in your service provider boot method, this package already does this for you. However, if you have your features in custom locations outside theApp\Features
directory, you need to register them using:
FilamentPennantServiceProvider::registerCustomFeatureLocations(['Modules\ACL\Features' => '/var/www/html/modules/ACL/Features']);
Create Class Based Feature
To create a class based feature, you may invoke the pennant:feature Artisan command.
php artisan pennant:feature WalletFunding
When writing a feature class, you only need to use the CK\FilamentPennant\Concerns\ResolvesFeatureSegments
trait, which will be invoked to resolve the feature's initial value for a given scope.
<?php namespace App\Features; use Laravel\Pennant\Feature; use Modules\Organization\Models\Organization; use CK\FilamentPennant\Concerns\ResolvesFeatureSegments; class RoleManagement { use ResolvesFeatureSegments; // You can optionally specify the scope of the feature // public function scope(): string // { // return User::class; // } }
You can see the trait for more things you can override like the defaultValue
property.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.