tomatophp / filament-plugins
使用插件生成器将模块作为插件系统进行管理
Requires
- php: ^8.1|^8.2
- calebporzio/sushi: *
- filament/filament: ^3.0.0
- filament/notifications: ^3.0.0
- nwidart/laravel-modules: ^11.0
- tomatophp/console-helpers: ^1.1
- tomatophp/filament-icons: ^1.0
README
Filament 插件管理器与生成器
使用插件生成器将模块作为插件系统进行管理
截图
安装
composer require tomatophp/filament-plugins
安装您的包后,请运行此命令
php artisan filament-plugins:install
默认情况下,模块类不会自动加载。您可以通过在额外部分添加 merge-plugin 来自动加载您的模块
"extra": { "laravel": { "dont-discover": [] }, "merge-plugin": { "include": [ "Modules/*/composer.json" ] } },
现在您需要运行此命令来自动加载您的模块
composer dump-autoload
最后,在 /app/Providers/Filament/AdminPanelProvider.php
上注册插件
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make())
使用
您可以使用命令创建一个新插件
php artisan filament-plugins:generate
或者您可以使用 GUI 创建新插件,创建插件后,请确保它通过运行此命令在 composer 中加载
composer dump-autoload
创建插件后,您可以在其中创建一个新表,然后运行迁移生成器将其转换为迁移文件,然后您可以使用 GUI 生成资源、页面、小部件或模型,或者您可以轻松使用这些命令
php artisan filament-plugins:model php artisan filament-plugins:resource php artisan filament-plugins:page php artisan filament-plugins:widget
它将为您生成文件,您可以直接使用它们,请注意,您需要首先生成模型,然后再使用其他命令
使用命令行安装插件
您可以使用此命令通过命令行安装插件
php artisan filament:plugins
您可以选择全部安装 TomatoPHP 生态系统中的所有插件,或者选择您想要安装的插件
所有 TomatoPHP 插件列表
您可以使用此命令列出所有 TomatoPHP 插件
php artisan filament-plugins:list
在插件列表中列出您的包
您可以通过在包根目录中添加一个名为 module.json
的 json 文件来在插件列表中列出您的包,内容如下
{ "name": "FilamentAccounts", "alias": "filament-accounts", "description": { "ar": "full accounts manager with API\/Notifications\/Contacts to manage your contacts and accounts", "en": "full accounts manager with API\/Notifications\/Contacts to manage your contacts and accounts", "gr": "full accounts manager with API\/Notifications\/Contacts to manage your contacts and accounts", "sp": "full accounts manager with API\/Notifications\/Contacts to manage your contacts and accounts" }, "keywords": [], "priority": 0, "providers": [ "TomatoPHP\\FilamentAccounts\\FilamentAccountsServiceProvider" ], "files": [], "title": { "ar": "Filament Accounts", "en": "Filament Accounts", "gr": "Filament Accounts", "sp": "Filament Accounts" }, "color": "#007dff", "icon": "heroicon-c-user-circle", "placeholder": "placeholder.webp", "type": "lib", "version": "v1.0", "github" : "https://github.com/tomatophp/filament-accounts", "docs" : "https://github.com/tomatophp/filament-accounts" }
确保您在 filament-plugins.php
配置文件中允许包扫描
'scan' => true
现在您可以通过使用此命令以非常简单的方式将您的包发布为模块
php artisan filament-plugins:publish
输入列表中的包名,它将将其移动到模块文件夹中,并为您注册提供者,因此您可以在包上自定义您喜欢的内容。
在您的面板中使用选定的模块
您可以通过在 PanelProvider 中使用此代码在您的面板中使用选定的模块
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make()->modules([ 'CRM' ]))
因此,您将只在面板中看到选定的模块
仅获取当前面板插件
在任何插件中,您都可以为选定的面板创建页面/资源/小部件,因此如果您需要仅显示当前面板的页面/资源/小部件,您可以在 PanelProvider 中使用此代码
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make()->discoverCurrentPanelOnly())
停止自动发现模块资源
您可以通过在 PanelProvider 中使用此代码停止自动加载模块资源
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make()->autoDiscoverModules(false))
停止使用插件 UI
您可以通过在 PanelProvider 中使用此代码停止使用插件 UI
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make()->useUI(false))
发布资产
您可以使用此命令发布配置文件
php artisan vendor:publish --tag="filament-plugins-config"
您可以使用此命令发布视图文件
php artisan vendor:publish --tag="filament-plugins-views"
您可以使用此命令发布语言文件
php artisan vendor:publish --tag="filament-plugins-lang"
您可以使用此命令发布迁移文件
php artisan vendor:publish --tag="filament-plugins-migrations"
其他 Filament 包
查看我们的Awesome TomatoPHP