bezhansalleh/filament-plugin-essentials
Composer 安装命令:
composer require bezhansalleh/filament-plugin-essentials
包简介
A collection of essential traits that streamline Filament plugin development by taking care of the boilerplate, so you can focus on shipping real features faster
README 文档
README
Filament Plugin Essentials
A collection of essential traits that streamline Filament plugin development by taking care of the boilerplate, so you can focus on shipping real features faster
Table of Contents
- Filament Plugin Essentials
Features
- Easily Configure
- 🎯 Navigation - Complete control over resource navigation (labels, icons, groups, sorting, badges)
- 🏷️ Label - Model labels, plural forms, title attributes, and casing options
- 🔍 Global Search - Searchability controls, result limits, and case sensitivity options
- 👥 Resource Tenant options - Tenant scoping and relationship configuration
- 🔗 Parent Resource - Hierarchical resource relationships
- ⚙️ Multi-Resource Configuration - Different settings per
Resourcein a single plugin - 📦 3-Tier Default System - User overrides → Plugin defaults → Filament defaults
- 🔄 Dynamic Values - Closure support for conditional logic and real-time data
- 🛠️ Developer-Friendly - Minimal boilerplate with maximum customization
Requirements
Installation
composer require bezhansalleh/filament-plugin-essentials
For Plugin Developers
1. Add traits to your plugin class
<?php namespace YourVendor\YourPlugin; use BezhanSalleh\PluginEssentials\Concerns\Plugin; use Filament\Contracts\Plugin; class YourPlugin implements Plugin { use Plugin\HasNavigation; use Plugin\HasLabels; use Plugin\HasGlobalSearch; use Plugin\WithMultipleResourceSupport; // For multi-forResource plugins public static function make(): static { return app(static::class); } public function getId(): string { return 'your-plugin'; } // ... rest of plugin implementation }
2. Add matching traits to your forResource classes
<?php namespace YourVendor\YourPlugin\Resources; use BezhanSalleh\PluginEssentials\Concerns; use Filament\Resources\Resource; class UserResource extends Resource { use Concerns\Resource\HasNavigation; use Concerns\Resource\HasLabels; use Concerns\Resource\HasGlobalSearch; protected static ?string $model = User::class; // Required: Link resource to plugin public static function getEssentialsPlugin(): ?YourPlugin { return YourPlugin::get(); } // ... rest of forResource implementation }
3. Set defaults for your plugin (optional)
class YourPlugin implements Plugin { use HasNavigation, HasLabels, HasGlobalSearch; protected function getPluginDefaults(): array { return [ // Global defaults (apply to all resources) 'navigationGroup' => 'Your Plugin', 'navigationIcon' => 'heroicon-o-puzzle-piece', 'modelLabel' => 'Item', 'pluralModelLabel' => 'Items', 'globalSearchResultsLimit' => 25, // Resource-specific defaults (optional) 'resources' => [ UserResource::class => [ 'modelLabel' => 'User', 'pluralModelLabel' => 'Users', 'navigationIcon' => 'heroicon-o-users', 'globalSearchResultsLimit' => 50, ], PostResource::class => [ 'modelLabel' => 'Post', 'pluralModelLabel' => 'Posts', 'navigationIcon' => 'heroicon-o-document-text', 'navigationSort' => 10, ], ], ]; } }
How Plugin Users Can Configure Your Plugin
When plugin developers use these traits, users of their plugins get a fluent API to configure them. The available configuration options depend on which traits the plugin developer chose to include.
Configure any plugin that uses these traits:
use YourVendor\YourPlugin\YourPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ YourPlugin::make() ->navigationLabel('Custom Label') ->navigationIcon('heroicon-o-star') ->modelLabel('Custom Item') ->globalSearchResultsLimit(30), ]); }
Multi-forResource configuration
YourPlugin::make() // Configure UserResource ->forResource(UserResource::class) ->navigationLabel('Users') ->modelLabel('User') ->globalSearchResultsLimit(25) // Configure PostResource ->forResource(PostResource::class) ->navigationLabel('Posts') ->modelLabel('Article') ->globalSearchResultsLimit(10)
Dynamic values with closures
YourPlugin::make() ->navigationLabel(fn() => 'Users (' . User::count() . ')') ->navigationBadge(fn() => User::whereNull('email_verified_at')->count()) ->modelLabel(fn() => auth()->user()->isAdmin() ? 'Admin User' : 'User')
Plugin & Resource Trait Mapping
Each plugin trait has a corresponding forResource trait that must be added to your forResource classes:
use BezhanSalleh\PluginEssentials\Concerns\Plugin; // plugin use BezhanSalleh\PluginEssentials\Concerns\Resource; // forResource
| Plugin Trait | Resource Trait |
|---|---|
Plugin\HasNavigation |
Resource\HasNavigation |
Plugin\HasLabels |
Resource\HasLabels |
Plugin\HasGlobalSearch |
Resource\HasGlobalSearch |
Plugin\BelongsToParent |
Resource\BelongsToParent |
Plugin\BelongsToTenant |
Resource\BelongsToTenant |
Plugin\WithMultipleResourceSupport |
(No forResource trait needed - enables multi-forResource configuration) |
Configuration Options Provided by Each Trait
HasNavigation
$plugin ->navigationLabel('Label') // string|Closure|null ->navigationIcon('heroicon-o-home') // string|Closure|null ->activeNavigationIcon('heroicon-s-home') // string|Closure|null ->navigationGroup('Group') // string|Closure|null ->navigationSort(10) // int|Closure|null ->navigationBadge('5') // string|Closure|null ->navigationBadgeColor('success') // string|array|Closure|null ->navigationParentItem('parent.item') // string|Closure|null ->slug('custom-slug') // string|Closure|null ->registerNavigation(false); // bool|Closure
Copy-paste defaults:
protected function getPluginDefaults(): array { return [ 'navigationLabel' => 'Your Label', 'navigationIcon' => 'heroicon-o-home', 'activeNavigationIcon' => 'heroicon-s-home', 'navigationGroup' => 'Your Group', 'navigationSort' => 10, 'navigationBadge' => null, 'navigationBadgeColor' => null, 'navigationParentItem' => null, 'slug' => null, 'registerNavigation' => true, ]; }
HasLabels
$plugin ->modelLabel('Model') // string|Closure|null ->pluralModelLabel('Models') // string|Closure|null ->recordTitleAttribute('name') // string|Closure|null ->titleCaseModelLabel(false); // bool|Closure
Copy-paste defaults:
protected function getPluginDefaults(): array { return [ 'modelLabel' => 'Item', 'pluralModelLabel' => 'Items', 'recordTitleAttribute' => 'name', 'titleCaseModelLabel' => true, ]; }
HasGlobalSearch
$plugin ->globallySearchable(true) // bool|Closure ->globalSearchResultsLimit(50) // int|Closure ->forceGlobalSearchCaseInsensitive(true) // bool|Closure|null ->splitGlobalSearchTerms(false); // bool|Closure
Copy-paste defaults:
protected function getPluginDefaults(): array { return [ 'globallySearchable' => true, 'globalSearchResultsLimit' => 50, 'forceGlobalSearchCaseInsensitive' => null, 'splitGlobalSearchTerms' => false, ]; }
BelongsToParent
$plugin->parentResource(ParentResource::class); // string|Closure|null
Copy-paste defaults:
protected function getPluginDefaults(): array { return [ 'parentResource' => null, ]; }
BelongsToTenant
$plugin ->scopeToTenant(true) // bool|Closure ->tenantRelationshipName('organization') // string|Closure|null ->tenantOwnershipRelationshipName('owner'); // string|Closure|null
Copy-paste defaults:
protected function getPluginDefaults(): array { return [ 'scopeToTenant' => true, 'tenantRelationshipName' => null, 'tenantOwnershipRelationshipName' => null, ]; }
WithMultipleResourceSupport
Enables per-forResource configuration:
class YourPlugin implements Plugin { use HasNavigation; use WithMultipleResourceSupport; } // Usage: $plugin ->forResource(UserResource::class) ->navigationLabel('Users') ->forResource(PostResource::class) ->navigationLabel('Posts');
Todo
- Add support for pages
- ...features you want to see? Open an issue
Testing
composer test:unit composer finalize
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.
bezhansalleh/filament-plugin-essentials 适用场景与选型建议
bezhansalleh/filament-plugin-essentials 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.23M 次下载、GitHub Stars 达 27, 最近一次更新时间为 2025 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Bezhan Salleh」 「filament-plugin-essentials」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bezhansalleh/filament-plugin-essentials 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bezhansalleh/filament-plugin-essentials 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bezhansalleh/filament-plugin-essentials 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 1.23M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 38
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-12