ibrostudio / filament-plugin-tools
这是我创建的包 filament-plugin-tools
v1.0.1
2022-06-05 07:56 UTC
Requires
- php: ^8.1
- doctrine/dbal: ^3.3
- filament/filament: ^2.12
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-09 04:55:25 UTC
README
此包用于Filament插件开发。
它简单地将原生Filament命令转换为插件上下文,以生成资源、页面和小部件。
注意
为了轻松入门,我们发布了Spatie的package-skeleton-laravel
的Filament版本,包括这些工具和其他一些好东西。查看这里:filament-plugin-skeleton
要求
假设你正在开发一个名为PluginName的插件。文件位于一个专门的目录中,称为packages。你已经在Laravel应用程序中本地导入插件以进行开发
在composer.json
{ "repositories": [ { "type": "path", "url": "../../packages/plugin-name" } ] }
然后
composer require vendor-name/plugin-name
自动注册
此包可以自动在插件服务提供者中注册资源、页面和小部件。
为此,请确保
- 你已将你的服务提供者的完全限定类名添加到插件composer.json文件中的extra.laravel.providers数组中
{ "extra": { "laravel": { "providers": [ "VendorName\\PluginName\\PluginNameServiceProvider" ] } } }
- 在插件的服务提供者文件中添加
$pages
、$resources
和$widgets
属性
use Filament\PluginServiceProvider; use Spatie\LaravelPackageTools\Package; class PluginNameServiceProvider extends PluginServiceProvider { protected array $pages = [ ]; protected array $resources = [ ]; protected array $widgets = [ ]; public function configurePackage(Package $package): void { $package->name('plugin-name'); } }
安装
使用composer在Laravel应用程序中安装filament-plugin-tools包
composer require ibrostudio/filament-plugin-tools --dev
使用方法
资源
php artisan make:filament-plugin-resource plugin-name Model
选项与原始命令相同
php artisan make:filament-plugin-resource plugin-name Model --simple php artisan make:filament-plugin-resource plugin-name Model --generate php artisan make:filament-plugin-resource plugin-name Model --view-page etc...
关系管理器
所有关系管理器都可用
php artisan make:filament-plugin-has-many ModelResource relationship attribute php artisan make:filament-plugin-has-many-through ModelResource relationship attribute php artisan make:filament-plugin-belongs-to-many ModelResource relationship attribute php artisan make:filament-plugin-morph-many ModelResource relationship attribute php artisan make:filament-plugin-morph-to-many ModelResource relationship attribute
页面
php artisan make:filament-plugin-page plugin-name PageName
选项也适用
php artisan make:filament-plugin-page plugin-name Model --resource=ModelResource --type=custom
小部件
php artisan make:filament-plugin-widget plugin-name WidgetName
使用资源选项
php artisan make:filament-plugin-widget plugin-name Model --resource=ModelResource
测试
composer test
致谢
- iBroStudio
- Filament团队,感谢他们的工作
许可
MIT许可证(MIT)。有关更多信息,请参阅许可文件。