PHPackages                             creativitykills/filament-pennant - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. creativitykills/filament-pennant

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

creativitykills/filament-pennant
================================

Manage Feature Flags using Laravel Pennant from Filament.

v4.0.0(2mo ago)02.8k↓40.9%[3 PRs](https://github.com/CreativityKills/filament-pennant/pulls)MITPHPPHP ^8.4CI passing

Since Jun 5Pushed 1mo agoCompare

[ Source](https://github.com/CreativityKills/filament-pennant)[ Packagist](https://packagist.org/packages/creativitykills/filament-pennant)[ Docs](https://github.com/creativitykills/filament-pennant)[ GitHub Sponsors](https://github.com/CreativityKills)[ RSS](/packages/creativitykills-filament-pennant/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (13)Used By (0)

Filament Pennant – Manage Laravel Pennant in FilamentPHP
========================================================

[](#filament-pennant--manage-laravel-pennant-in-filamentphp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7f3cd296dd12c3fd221305951ae5a316270c9406a6ca3448986f676a8f811d61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637265617469766974796b696c6c732f66696c616d656e742d70656e6e616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creativitykills/filament-pennant)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1fa7c5001d13a94bbf9c42630fba25ad7ac98ce5dae760a58353ec4e77b67ecb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f637265617469766974796b696c6c732f66696c616d656e742d70656e6e616e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/creativitykills/filament-pennant/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b4ebed76483a06c1146ec7d6fce4bad86cc75fb4982af5c81cb376b0b1679bdb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f637265617469766974796b696c6c732f66696c616d656e742d70656e6e616e742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/creativitykills/filament-pennant/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/776d5620d022ef7c066b338277de87cc62bb15a20fb2c6e756351a42d18b3687/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f637265617469766974796b696c6c732f66696c616d656e742d70656e6e616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creativitykills/filament-pennant)

This plugin is heavily inspired by [this plugin](https://github.com/stephenjude/filament-feature-flags). There are several improvements including but not limited to:

- Support for [scoped feature flags](https://laravel.com/docs/12.x/pennant#specifying-the-scope)
- Support for Features in custom directories
- and more...

[![](https://raw.githubusercontent.com/creativitykills/filament-pennant/main/art/screenshot-1.png)](https://raw.githubusercontent.com/creativitykills/filament-pennant/main/art/screenshot-1.png)

Installation
------------

[](#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
-----

[](#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 the `App\Features` directory, you need to register them using:
>
> `FilamentPennantServiceProvider::registerCustomFeatureLocations(['Modules\ACL\Features' => '/var/www/html/modules/ACL/Features']);`

Create Class Based Feature
--------------------------

[](#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.

```
