- How do I install coolsam/modules for Laravel Filament?
- Run `composer require coolsam/modules`, then execute `php artisan modules:install` to set up the base configuration. Ensure your Laravel version is 11/12 and Filament is 4.x/5.x, as these are explicitly supported. The package depends on `nwidart/laravel-modules`, which will be auto-installed.
- Can I use this package with Filament 3.x or Laravel 10?
- No, this package (v5.x) only supports Filament 4.x/5.x and Laravel 11/12/13. For Filament 3.x or Laravel 10, you must use version 3.x or 4.x of the package, respectively. Check the [README](https://github.com/coolsam726/filament-modules) for version-specific documentation.
- How do I create a Filament resource inside a module?
- Use the artisan command `php artisan module:filament:resource Invoice --module=BillingModule`. This generates the resource in the module’s directory structure and registers it automatically. Ensure your module is properly initialized with `php artisan module:filament:install BillingModule` first.
- What’s the difference between `PLUGINS` and `PANELS` mode in the config?
- `PLUGINS` mode dynamically loads modules as Filament plugins, ideal for feature toggling or isolated updates. `PANELS` mode creates dedicated Filament panels for each module, useful for complete separation (e.g., multi-tenancy). Choose based on whether you need modular plugins or standalone admin sections.
- Will modules work with shared database connections or schemas?
- Modules support isolated database configurations (e.g., module-specific tables), but shared connections (like PostgreSQL schemas) must be manually managed. Use `module:publish` to customize migrations or define shared schemas in your module’s `ModuleServiceProvider`. Test with `php artisan migrate --path=modules/BillingModule/database/migrations`.
- How do I test a module in isolation from the main Filament panel?
- Enable test mode with `ModulesPlugin::testMode(true)` in your test setup. This prevents the module from auto-registering in the main panel, allowing you to test resources, pages, or widgets independently. Useful for CI/CD pipelines or unit testing Filament components.
- Can I deploy modules independently as Composer packages?
- Yes, modules can be versioned as standalone Composer packages. Use `composer require vendor/module-name` to install them dynamically. Ensure each module has its own `composer.json` with `extra.laravel-modules` configuration. For production, test cold starts with `opcache.reset()` to measure autoloading overhead.
- How do I handle permission policies for module-specific resources?
- Extend Filament’s `CanAccessTrait` or integrate with its built-in policies. For example, create a `BillingModulePolicy` in your module’s `app/Policies` directory and attach it to the module’s resources. Use `php artisan module:filament:policy Invoice --module=BillingModule` to scaffold a policy.
- What are Filament clusters, and how do I enable them?
- Clusters group related Filament resources (Resources, Pages, Widgets) under a module’s navigation label (e.g., ‘Billing’). Enable them by setting `clusters.enabled = true` in `config/filament-modules.php` and use `php artisan module:filament:cluster BillingCluster --module=BillingModule` to create one.
- Are there performance concerns with module autoloading in production?
- Module autoloading adds minimal overhead if configured correctly. Use Composer’s `merge-plugin` to optimize autoloading paths. For cold starts, test with `opcache.reset()` and monitor memory usage. If performance is critical, consider preloading modules via `bootstrap/app.php` or using `PLUGINS` mode for lazy loading.