bezhansalleh/filament-plugin-essentials
A collection of essentials for Filament plugins: shared helpers, patterns, and base components to speed up building and maintaining Filament extensions. Provides common utilities and sensible defaults so you can ship plugins faster with less boilerplate.
HasResources, HasWidgets, HasPolicies) to enable selective adoption—ideal for incremental plugin maturation without monolithic refactoring.Filament::plugin()) for seamless integration into existing Laravel apps. No core framework modifications required.filament/filament (≥v3.0), laravel/framework.spatie/laravel-permission for policy traits).PluginTestCase), but requires manual validation of trait interactions with custom logic.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Filament Version Drift | High | Pin exact Filament version in composer.json; monitor Filament’s deprecations. |
| Trait Collisions | Medium | Audit plugin codebase for conflicting trait methods (e.g., boot()). |
| Policy/Resource Leaks | Medium | Use plugin:unregister hooks for cleanup. |
| Performance Overhead | Low | Profile with tideways/xhprof if plugins scale to 100+ resources. |
Plugin Isolation:
HasWidgets)?app()->makeWith())?Customization Limits:
HasResources with custom table columns) without subclassing?afterResourceRegistered)?Testing & Debugging:
PluginRegistrationException) surfaced in logs?Long-Term Viability:
RouteServiceProvider)?| Phase | Actionable Steps |
|---|---|
| Assessment | Audit existing plugins for traits that can be replaced (e.g., manual Resource registration). |
| Pilot | Migrate one low-criticality plugin (e.g., a dashboard widget) to test traits. |
| Rollout | Replace ServiceProvider boilerplate with HasResources trait for all plugins. |
| Optimization | Use plugin:extend to add custom logic to trait methods (e.g., configureTable). |
app()->plugin() macro behavior with Laravel’s new context binding.Vendor/PluginName).composer require bezhansalleh/filament-plugin-essentials.config/app.php.Resource::for() with use HasResources; class MyPlugin extends Plugin { ... }.HasPolicies trait.php artisan filament:plugins to verify registration.php artisan plugin:unregister MyPlugin).HasPolicies).Xdebug configuration (e.g., ide_helper:generate).Class 'HasResources' not found → Verify use statements and autoloading.CanAccessPlugin trait implementation.memory_get_usage()).filament:resources:list).HasResources calling HasWidgets in boot()).| Scenario | Impact | Mitigation |
|---|---|---|
| Trait method conflicts | Plugin breaks on update | Use plugin:override to shadow methods. |
| Filament major version update | Package incompatibility | Fork and maintain locally if needed. |
| Policy trait misconfiguration | RBAC failures | Audit HasPolicies gate definitions. |
| Plugin registration race | Duplicate resources | Use Singleton pattern in traits. |
HasResources + HasWidgets).plugin:extend.ServiceProvider with Plugin class.
[ ] Migrate policies to HasPolicies.
[ ] Test plugin unloading.How can I help you explore Laravel packages today?