- How do I integrate Filament modules into an existing Laravel project that isn’t using nwidart/laravel-modules?
- First, install `nwidart/laravel-modules` and set up your modular structure. Then, add `savannabits/filament-modules` to create Filament-specific modules. The package provides commands to scaffold Filament clusters, plugins, resources, and pages within modules. Start with a single module to test the workflow before expanding.
- Can I use this package with Filament 5.x in production, or should I stick to Filament 4.x for stability?
- Filament 5.x support is marked as experimental in this package, so production use is not recommended until further stabilization. Stick to Filament 4.x for now unless you’re actively monitoring the changelog for breaking changes or have tested the package thoroughly in a staging environment.
- How do I create a new Filament resource, page, or widget within a module?
- Use the package’s Artisan commands: `filament:module-resource`, `filament:module-page`, or `filament:module-widget`. These commands generate the files in the correct module directory and register them automatically under the module’s cluster. No manual configuration is needed for basic setups.
- What’s the difference between a ‘cluster’ and a ‘plugin’ in this package?
- A **cluster** groups Filament components (resources, pages, widgets) under a module for navigation and logical separation, while a **plugin** encapsulates reusable Filament functionality (e.g., a dashboard module). Clusters improve UX by organizing components, while plugins enable modular reuse across projects.
- How does this package handle database migrations for module-specific tables?
- Migrations are managed per module via `nwidart/laravel-modules`, which runs them in the correct order during module bootstrapping. Ensure your module’s `ModuleServiceProvider` includes the migration file, and use `php artisan module:migrate` to apply changes. Avoid naming conflicts by prefixing tables with your module namespace.
- Can I customize the navigation structure (e.g., top-level vs. side navigation) for module clusters?
- Yes, configure the `clusters.use-top-navigation` setting in your Filament panel’s configuration. Set it to `true` for top-level navigation or `false` for side sub-navigation. This is useful for aligning with your admin panel’s hierarchy, especially in complex dashboards with multiple domains.
- Will this package work with existing Filament plugins (e.g., Spatie Laravel Media Library, Filament Tables) in my modules?
- Yes, the package integrates with Filament’s plugin system. Existing plugins can be included in modules as long as they’re compatible with your Filament version. The `ModulesPlugin` auto-registers module-specific plugins, so no additional manual registration is required for most cases.
- How do I test Filament components that are part of a module in isolation?
- Use Filament’s built-in testing helpers (e.g., `actingAs`, `get()`) alongside module-specific bootstrapping. Mock the `ModulesPlugin` in tests to isolate module components. For database-driven tests, use `ModuleTestCase` from `nwidart/laravel-modules` to ensure migrations and seeders run in the correct context.
- What’s the performance impact of using multiple Filament modules, and how can I mitigate it?
- Each module loads its own Filament components, which can increase memory usage if modules are numerous or resource-heavy. Mitigate this by enabling Filament’s caching (e.g., `config(['filament.cache' => true])`) and lazy-loading non-critical modules. Avoid over-modularizing—group related functionality into fewer modules where possible.
- Are there alternatives to this package for modularizing Filament admin panels?
- If you’re not using `nwidart/laravel-modules`, consider Filament’s built-in plugin system for simpler modularization or packages like `filament/spatie-laravel-medialibrary-plugin` for domain-specific integrations. However, for large-scale projects requiring feature isolation and independent deployability, `savannabits/filament-modules` is the most aligned solution.