ibrostudio / filament-plugin-tools
This is my package filament-plugin-tools
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-11-09 05:22:24 UTC
README
This package is for Filament plugin development.
It simply converts the native Filament commands to a plugin context to generate resources, pages and widgets.
Note
To get started easily, we released a Filament version of the Spatie's package-skeleton-laravel, including this tools and others goodies. Check it out here : filament-plugin-skeleton
Requirements
Let's say you are developing a plugin called PluginName. Files are located in a dedicated directory, called packages. You have locally imported the plugin in a Laravel app for development:
In composer.json:
{ "repositories": [ { "type": "path", "url": "../../packages/plugin-name" } ] }
Then:
composer require vendor-name/plugin-name
Auto-registering
This package can auto-register resources, pages and widgets in your plugin service provider.
For that, ensure that:
- You added your service provider's fully qualified class name to the extra.laravel.providers array in your plugin's composer.json file:
{ "extra": { "laravel": { "providers": [ "VendorName\\PluginName\\PluginNameServiceProvider" ] } } }
- Add the properties
$pages
,$resources
and$widgets
in the plugin's service provider file:
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'); } }
Installation
Install the filament-plugin-tools package in your Laravel app via composer:
composer require ibrostudio/filament-plugin-tools --dev
Usage
Resources
php artisan make:filament-plugin-resource plugin-name Model
The options work as with the original commands:
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...
Relation managers
All relations managers are availables:
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
Pages
php artisan make:filament-plugin-page plugin-name PageName
Options work too:
php artisan make:filament-plugin-page plugin-name Model --resource=ModelResource --type=custom
Widgets
php artisan make:filament-plugin-widget plugin-name WidgetName
With resource option:
php artisan make:filament-plugin-widget plugin-name Model --resource=ModelResource
Testing
composer test
Credits
- iBroStudio
- The Filament team, thanks to them for their work
License
The MIT License (MIT). Please see License File for more information.