Search by

packstub / filament-features

icaliman

Feature flags and entitlements for Filament tenants — plan-based features and limits, per-tenant overrides, kill switches, usage checks, and gating for pages, actions, routes and Blade.

Package info

github.com/packstub/filament-features

Homepage

Documentation

pkg:composer/packstub/filament-features

Fund package maintenance!

icaliman

Statistics

Installs: 7

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.1.1 2026-11-17 12:31 UTC

This package is auto-updated.

Last update: 2026-11-17 12:31:30 UTC


README

Filament Features — plans, limits and flags per tenant

Latest Version on Packagist Tests Total Downloads License Sponsor

Feature flags and entitlements for Filament v5 tenants: define features and plans in code, store per-tenant overrides and global kill switches, check limits against real usage, and gate pages, actions, routes and Blade with one call.

Switching from a Pro team to a Free team: the same Reports page shows an upgrade card, and Upgrade opens the plan page with its limits and usage

Features

  • Features and plans in code: on/off features and numeric limits, bundled into plans; the plan comes from any source.
  • One call to check: whether a feature is on, its limit and what's left against real usage.
  • Gating everywhere: routes, actions, form fields, pages and Blade, with an upgrade card when something is locked.
  • Overrides: trials, beta access and custom limits per tenant, global kill switches, each with an expiry and a reason.
  • Plan and admin pages: "Your plan" with usage bars for tenants, flags and overrides for operators.
  • Works with Filament Teams: seat limits straight from the plan.
  • Caching, commands and events: a per-request memo with an optional cache store, list and prune commands, events when a limit is hit.

Compatibility

Plugin Filament Laravel PHP
1.x 5.x 12.x, 13.x 8.3+

Installation

composer require packstub/filament-features
php artisan packstub-features:install
use Packstub\Features\FeaturesPlugin;

$panel->plugin(
    FeaturesPlugin::make()
        ->features([
            'api_access' => ['label' => 'API access', 'type' => 'boolean', 'default' => false, 'group' => 'Integrations'],
            'projects'   => ['label' => 'Projects', 'type' => 'limit', 'default' => 3, 'unit' => 'projects'],
        ])
        ->plans([
            'free' => ['label' => 'Free', 'features' => ['projects' => 3]],
            'pro'  => ['label' => 'Pro', 'price' => '$29', 'features' => ['projects' => 50, 'api_access' => true]],
        ], default: 'free')
        ->planUsing(fn (?Team $team) => $team?->subscription?->plan)   // or a `plan` column
        ->usage('projects', fn (?Team $team) => $team?->projects()->count() ?? 0)
        ->upgradeUrl(fn (?Team $team) => route('billing', $team)),
);

Optionally add Packstub\Features\Concerns\HasFeatures to the tenant model for $team->hasFeature('api_access'), featureLimit(), featureRemaining(), canUseFeature().

Checking

Features::active('api_access');            // current Filament tenant
Features::active('api_access', $team);
Features::limit('projects', $team);        // 50, or null = unlimited
Features::remaining('projects', $team);
Features::canUse('projects', $team);
Features::assertCanUse('projects', $team); // throws FeatureLimitReached / FeatureInactive
Features::for($team)->snapshot();          // every feature with value, source, usage
Route::get('/api/tokens', ...)->middleware('feature:api_access');          // 403
Route::get('/reports', ...)->middleware('feature:reports,redirect');       // → upgrade URL

Action::make('export')->requiresFeature('api_access');
TextInput::make('webhook_url')->requiresFeature('api_access');

class ReportsPage extends Page { use RequiresFeature; protected static string $feature = 'reports'; }
@feature('api_access') … @else … @endfeature
<x-packstub-features::locked feature="api_access" />

Overrides

Features::enable($team, 'reports', now()->addDays(14), 'trial');
Features::override($team, 'projects', 100, reason: 'enterprise deal');
Features::override($team, 'projects', null);        // unlimited
Features::disable(null, 'api_access');              // global kill switch
Features::clearOverride($team, 'reports');

Resolution order: scope override → plan → global override → default.

Pages

  • Plan (tenant panel, /plan) — "Your plan": features by group, usage bars, upgrade button. Disable with ->planPage(null).
  • FeatureFlags and FeatureOverrides (central/admin panel) — ->adminPages(). Open to whoever can access a panel without tenancy; on a tenant panel they stay hidden unless ->canManageUsing(fn (User $user) => ...) (or a manageFeatures Gate ability) says otherwise.

With Filament Teams

TeamsPlugin::make()->seatLimit(fn (Team $team) => Features::limit('seats', $team));

Configuration

See config/packstub-features.php: scope_model, features, plans, default_plan, overrides_table, connection, cache.store / ttl, upgrade_url. Anything can be overridden per panel with ->config([...]).

Commands: features:list prints every feature with its resolved value for a tenant, features:prune deletes expired overrides.

Documentation

The same pages live in the docs/ directory of this repository.

Testing

composer test

Changelog

See the changelog.

Contributing

See CONTRIBUTING.

Security

See our security policy.

Credits

License

The MIT License (MIT). See LICENSE.