packstub / filament-features
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.
Fund package maintenance!
Requires
- php: ^8.3
- filament/filament: ^5.0
- illuminate/contracts: ^12.0 || ^13.0
- spatie/laravel-package-tools: ^1.92
Requires (Dev)
- laravel/pint: ^1.27
- orchestra/testbench: ^10.0 || ^11.0
- pestphp/pest: ^4.0 || ^5.0
- pestphp/pest-plugin-laravel: ^4.0 || ^5.0
- pestphp/pest-plugin-livewire: ^4.0 || ^5.0
Suggests
- packstub/filament-teams: Drive team seat limits from a plan feature.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-17 12:31:30 UTC
README
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.
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).FeatureFlagsandFeatureOverrides(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 amanageFeaturesGate 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.

