Automatic Filament Panel Provider discovery for modular Laravel applications with intelligent caching and performance optimization.
Modulite automatically discovers and registers Filament panels and components across your modular application structure, eliminating the need for manual registration while providing production-ready performance optimizations.
nwidart/laravel-modules and panicdevs/modulesInstall via Composer:
composer require panicdevs/modulite
Publish the configuration file:
php artisan vendor:publish --tag=modulite-config
php artisan modulite:cacheAdd the ModulitePlugin to each panel where you want component discovery:
// In your Panel Provider (e.g., AdminPanelProvider.php)
use PanicDevs\Modulite\Plugins\ModulitePlugin;
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('/admin')
->plugins([
ModulitePlugin::make(), // Add this to discover components
// ... other plugins
])
// ... other panel configuration
}
That's it! Modulite will automatically discover and register components for this panel.
Modulite works on two levels:
For a module named User, Modulite expects this structure:
modules/
├── User/
│ ├── Providers/
│ │ └── Filament/
│ │ └── Panels/
│ │ └── UserPanelProvider.php # Panel definition
│ └── Filament/
│ ├── Admin/ # For 'admin' panel
│ │ ├── Resources/
│ │ │ └── UserResource.php
│ │ ├── Pages/
│ │ │ └── UserDashboard.php
│ │ └── Widgets/
│ │ └── UserStatsWidget.php
│ └── Manager/ # For 'manager' panel
│ └── Resources/
│ └── ProfileResource.php
ModulitePlugin is registered with specific panels for component discoveryConfigure caching behavior for optimal performance:
'cache' => [
'enabled' => env('MODULITE_CACHE_ENABLED', !app()->hasDebugModeEnabled()),
'file' => base_path('bootstrap/cache/modulite.php'),
'ttl' => env('MODULITE_CACHE_TTL', app()->hasDebugModeEnabled() ? 300 : 0),
'auto_invalidate' => app()->hasDebugModeEnabled(),
],
Key Settings:
enabled: Master cache toggle (auto: off in development, on in production)ttl: Cache lifetime in seconds (0 = never expires, recommended for production)auto_invalidate: Automatically clear cache when files change (development only)Define where to scan for components:
'panels' => [
'locations' => [
'modules/*/Providers/Filament/Panels',
'foundation/*/Providers/Filament/Panels',
],
],
'components' => [
'locations' => [
'modules/*/Filament/{panel}/Resources',
'modules/*/Filament/{panel}/Pages',
'modules/*/Filament/{panel}/Widgets',
],
],
Placeholders:
*: Module wildcard (e.g., User, Blog){panel}: Panel ID placeholder (e.g., Admin, Manager)Control how strict discovery validation should be:
'panels' => [
'validation' => [
'strict_inheritance' => env('MODULITE_STRICT_INHERITANCE', false),
'must_extend' => 'Filament\PanelProvider',
'must_be_instantiable' => true,
'allow_custom_base_classes' => env('MODULITE_ALLOW_CUSTOM_BASE_CLASSES', true),
],
],
When to Use:
strict_inheritance => true: Enforces exact class inheritanceallow_custom_base_classes => false: Only allows direct Filament class inheritanceChoose your module management approach:
'modules' => [
'approach' => env('MODULITE_APPROACH', 'panicdevs'), // or 'nwidart'
'scan_only_enabled' => true,
'respect_module_priority' => true,
],
Configure for production performance:
'performance' => [
'lazy_discovery' => env('MODULITE_LAZY_DISCOVERY', true),
'memory_optimization' => [
'batch_size' => 100,
'clear_stat_cache' => true,
'gc_after_scan' => true,
],
],
Set these in your .env for easy configuration:
# Cache Control
MODULITE_CACHE_ENABLED=true
MODULITE_CACHE_TTL=0
# Performance
MODULITE_LAZY_DISCOVERY=true
MODULITE_STATIC_CACHING=true
# Validation
MODULITE_STRICT_INHERITANCE=false
MODULITE_ALLOW_CUSTOM_BASE_CLASSES=true
# Debugging
MODULITE_LOGGING_ENABLED=false
# Cache all discoveries for production
php artisan modulite:cache
# Clear caches when needed
php artisan modulite:cache --force
# Check status and performance
php artisan modulite:status
# Detailed diagnostics
php artisan modulite:status --vvv
php artisan optimizephp artisan modulite:cacheThe cache system works like Laravel's bootstrap cache:
# Cache file location
bootstrap/cache/modulite.php
# Clear with Laravel caches
php artisan optimize:clear
# Or clear specifically
php artisan modulite:cache --force
php artisan modulite:status
This shows:
No panels discovered:
PanelProviderPerformance issues:
MODULITE_CACHE_ENABLED=trueMODULITE_CACHE_TTL=0php artisan modulite:cacheComponents not showing:
Resource, Page, Widget)Enable detailed logging in development:
MODULITE_LOGGING_ENABLED=true
MODULITE_LOG_LEVEL=debug
Clear all caches if you encounter stale data:
php artisan modulite:cache --force
php artisan optimize:clear
Modulite automatically optimizes for production:
You can use custom base classes for components:
'components' => [
'types' => [
'resources' => [
'allow_custom_base_classes' => true,
'strict_inheritance' => false,
],
],
],
For edge cases, disable auto-discovery and register manually:
'components' => [
'registration' => [
'auto_register' => false,
],
],
Modulite automatically handles multiple panels per module. Each panel needs the plugin registered for component discovery:
// AdminPanelProvider.php
public function panel(Panel $panel): Panel
{
return $panel
->id('admin')
->plugins([
ModulitePlugin::make(),
]);
}
// ManagerPanelProvider.php
public function panel(Panel $panel): Panel
{
return $panel
->id('manager')
->plugins([
ModulitePlugin::make(),
]);
}
Components are discovered based on directory structure:
modules/User/Filament/
├── Admin/Resources/UserResource.php # Registers to 'admin' panel
├── Manager/Resources/ProfileResource.php # Registers to 'manager' panel
└── Public/Pages/LoginPage.php # Registers to 'public' panel
Made with ❤️ by PanicDevs
How can I help you explore Laravel packages today?