creativitykills/filament-pennant

Manage Feature Flags using Laravel Pennant from Filament.

v0.0.3 2025-06-06 12:02 UTC

This package is auto-updated.

Last update: 2025-06-06 12:03:07 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This plugin is heavily inspired by this plugin. There are several improvements including but not limited to:

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 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

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.