bambamboole/filament-settings
Composer 安装命令:
composer require bambamboole/filament-settings
包简介
Manage application settings with a Filament UI
README 文档
README
A database-driven settings plugin for Filament. Settings are organised into groups, edited through a tabbed Filament page, and read anywhere via the settings() helper or the typed SettingsRepository methods.
Installation
composer require bamamboole/filament-settings
Publish and run the migration:
php artisan vendor:publish --tag="filament-settings-migrations"
php artisan migrate
Setup
Register the plugin in your panel provider and pass your SettingGroup classes:
use Bamamboole\FilamentSettings\FilamentSettingsPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentSettingsPlugin::make() ->groups([ GeneralSettings::class, MailSettings::class, ]), ]); }
Generating a Setting Group
Use the Artisan command to scaffold a new SettingGroup class interactively:
php artisan settings:make-group
The command asks for a class name, group key, and label, then writes the skeleton to app/Settings/{ClassName}.php:
┌ Class name ──────────────────────────────────────────────────┐
│ GeneralSettings │
└──────────────────────────────────────────────────────────────┘
┌ Group key ───────────────────────────────────────────────────┐
│ general │
└──────────────────────────────────────────────────────────────┘
┌ Label ───────────────────────────────────────────────────────┐
│ General │
└──────────────────────────────────────────────────────────────┘
◇ Created: app/Settings/GeneralSettings.php
The group key is derived automatically from the class name (GeneralSettings → general, MailNotificationSettings → mail-notification). Accept the defaults or type a custom value.
After generation, open the file and fill in schema() with Filament form components and optionally add casts(), icon(), and sort().
Defining a Setting Group
Create a class that extends SettingGroup. The key() is used as the DB prefix and the tab identifier; schema() returns standard Filament form components:
use Bamamboole\FilamentSettings\SettingGroup; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Support\Icons\Heroicon; class GeneralSettings extends SettingGroup { public static function key(): string { return 'general'; } public function label(): string { return 'General'; } public function icon(): Heroicon { return Heroicon::OutlinedCog6Tooth; } public function sort(): int { return 0; } public function casts(): array { return [ 'launched' => 'boolean', ]; } public function schema(): array { return [ TextInput::make('site_name')->label('Site Name')->maxLength(255), Toggle::make('launched')->label('Launched'), ]; } }
Field name convention
Form field names use snake_case (e.g. site_name). They are stored in the database as kebab-case keys prefixed with the group key (e.g. general.site-name).
Casts
Declare non-string fields in casts(). Supported types: boolean, integer. Everything else is returned as a raw string.
Access control per group
Override canAccess() on a group to hide it from certain users:
public static function canAccess(): bool { return auth()->user()->isAdmin(); }
Reading Settings
Helper function
// Get a value (returns null when not set) $name = settings('general.site-name'); // Get with a default $name = settings('general.site-name', 'My App'); // Access the repository directly settings()->set('general.site-name', 'New Name');
Typed repository methods
settings()->bool('general.launched', false); settings()->int('general.max-items', 10); settings()->string('general.site-name', 'My App'); settings()->array('general.allowed-ips', []);
Injecting the repository
use Bamamboole\FilamentSettings\SettingsRepository; class SomeService { public function __construct(private SettingsRepository $settings) {} public function isLaunched(): bool { return $this->settings->bool('general.launched'); } }
Caching
Caching is enabled by default. All settings for each tenant are loaded and cached in a single cache entry per tenant. Casts from all registered groups are cached together in one additional entry.
| Cache key | Contains |
|---|---|
settings.global |
All settings where team_id IS NULL |
settings.{id} |
All settings for tenant with that ID |
settings.casts |
Combined cast map from all SettingGroups |
The tenant bucket is automatically invalidated whenever a setting is saved or deleted. Configure the TTL or disable caching in config/filament-settings.php:
'cache' => [ 'enabled' => env('SETTINGS_CACHE_ENABLED', true), 'ttl' => env('SETTINGS_CACHE_TTL', 3600), ],
Multi-Tenancy
All settings have a team_id column. A global scope filters every query to the current tenant automatically. When team_id is null, the global (non-tenant) settings are used.
Configure the active tenant via the plugin:
FilamentSettingsPlugin::make() ->groups([...]) ->tenant(fn () => auth()->user()->team_id),
When using Filament's built-in tenancy, Filament::getTenant() is used automatically — no manual configuration needed.
Plugin Options
| Method | Description |
|---|---|
groups(array) |
SettingGroup classes to register |
canAccess(Closure) |
Guard access to the entire settings page |
tenant(Closure) |
Custom resolver for the current tenant ID |
navigationSort(int) |
Position in the sidebar (default: 99) |
navigationGroup(?string) |
Sidebar group label (default: none) |
Testing
composer test
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.
bambamboole/filament-settings 适用场景与选型建议
bambamboole/filament-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 383 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「filament」 「bambamboole」 「filament-plugin」 「filamentphp」 「filament-settings」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bambamboole/filament-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bambamboole/filament-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bambamboole/filament-settings 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A laravel package to dump missing translation keys into the translation files
A laravel package to effortlessly sync translations with Lokalise
A laravel package which provides a smooth OAS workflow
This is my package laravel-mermaid-erd
Create menus with ease in Filament
Alfabank REST API integration
统计信息
- 总下载量: 383
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-25