From 0493ad05af292fb89c554c2b99247099dee8365b Mon Sep 17 00:00:00 2001 From: Luiz Amadeu Date: Fri, 25 Sep 2026 10:42:57 -0300 Subject: [PATCH 1/2] Document Filament and Livewire usage in modules --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/README.md b/README.md index c0e124e..9b7c2bd 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,73 @@ at: You could access those translations with: `__('demo::messages.welcome');` +### Filament + +Filament resources, pages, and widgets can live inside a module. Create a +[Filament plugin](https://filamentphp.com/docs/5.x/advanced/modular-architecture) in your module +that discovers the module's Filament classes, and register that plugin in your panel: + +```php +// app-modules/blog/src/BlogPlugin.php +namespace Modules\Blog; + +use Filament\Contracts\Plugin; +use Filament\Panel; + +class BlogPlugin implements Plugin +{ + public static function make(): static + { + return app(static::class); + } + + public function getId(): string + { + return 'blog'; + } + + public function register(Panel $panel): void + { + $panel->discoverResources( + in: __DIR__.'/Filament/Resources', + for: 'Modules\\Blog\\Filament\\Resources', + ); + } + + public function boot(Panel $panel): void + { + } +} +``` + +```php +// app/Providers/Filament/AdminPanelProvider.php +$panel->plugins([ + \Modules\Blog\BlogPlugin::make(), +]); +``` + +Filament's `make:filament-*` commands don't accept `--module`, but once the plugin is registered they +will ask where to create the file, and you can pick your module's plugin. + +### Livewire + +Livewire's `make:livewire` command doesn't support the `--module` option. Create the component +class in your module manually and register it from your module's service provider: + +```php +use Livewire\Livewire; +use Modules\Blog\Livewire\EditPost; + +public function boot(): void +{ + Livewire::component('blog::edit-post', EditPost::class); +} +``` + +You can then render it with ``, and point the component's `render()` +method at a module view such as `view('blog::livewire.edit-post')`. + ### Customizing the Default Module Structure When you call `make:module`, Modular will scaffold some basic boilerplate for you. If you From 1082144fa89e94eccefb36d6b27eb3818d54f164 Mon Sep 17 00:00:00 2001 From: Luiz Amadeu Date: Thu, 19 Nov 2026 17:20:38 -0300 Subject: [PATCH 2/2] Show page and widget discovery, and where the module provider is registered The Filament example now discovers pages and widgets too, matching what the section says. Filament skips the directories that do not exist. The Livewire section now says that the module's service provider is already registered through package discovery. --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9b7c2bd..306e4f8 100644 --- a/README.md +++ b/README.md @@ -235,10 +235,19 @@ class BlogPlugin implements Plugin public function register(Panel $panel): void { - $panel->discoverResources( - in: __DIR__.'/Filament/Resources', - for: 'Modules\\Blog\\Filament\\Resources', - ); + $panel + ->discoverResources( + in: __DIR__.'/Filament/Resources', + for: 'Modules\\Blog\\Filament\\Resources', + ) + ->discoverPages( + in: __DIR__.'/Filament/Pages', + for: 'Modules\\Blog\\Filament\\Pages', + ) + ->discoverWidgets( + in: __DIR__.'/Filament/Widgets', + for: 'Modules\\Blog\\Filament\\Widgets', + ); } public function boot(Panel $panel): void @@ -260,9 +269,12 @@ will ask where to create the file, and you can pick your module's plugin. ### Livewire Livewire's `make:livewire` command doesn't support the `--module` option. Create the component -class in your module manually and register it from your module's service provider: +class in your module manually and register it from your module's service provider. Modules created +with `make:module` already have one, and Laravel loads it through package discovery (it is listed +under `extra.laravel.providers` in the module's `composer.json`), so there is nothing else to register: ```php +// app-modules/blog/src/Providers/BlogServiceProvider.php use Livewire\Livewire; use Modules\Blog\Livewire\EditPost;