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/modules
Install via Composer:
composer require panicdevs/modulite
Publish the configuration file:
php artisan vendor:publish --tag=modulite-config
php artisan modulite:cache
Add 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 ControlMODULITE_CACHE_ENABLED=trueMODULITE_CACHE_TTL=0 # PerformanceMODULITE_LAZY_DISCOVERY=trueMODULITE_STATIC_CACHING=true # ValidationMODULITE_STRICT_INHERITANCE=falseMODULITE_ALLOW_CUSTOM_BASE_CLASSES=true # DebuggingMODULITE_LOGGING_ENABLED=false
# Cache all discoveries for productionphp artisan modulite:cache # Clear caches when neededphp artisan modulite:cache --force # Check status and performancephp artisan modulite:status # Detailed diagnosticsphp artisan modulite:status --vvv
php artisan optimize
php artisan modulite:cache
The cache system works like Laravel's bootstrap cache:
# Cache file locationbootstrap/cache/modulite.php # Clear with Laravel cachesphp artisan optimize:clear # Or clear specificallyphp artisan modulite:cache --force
php artisan modulite:status
This shows:
No panels discovered:
PanelProvider
Performance issues:
MODULITE_CACHE_ENABLED=true
MODULITE_CACHE_TTL=0
php artisan modulite:cache
Components not showing:
Resource
, Page
, Widget
)Enable detailed logging in development:
MODULITE_LOGGING_ENABLED=trueMODULITE_LOG_LEVEL=debug
Clear all caches if you encounter stale data:
php artisan modulite:cache --forcephp 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.phppublic function panel(Panel $panel): Panel{ return $panel ->id('admin') ->plugins([ ModulitePlugin::make(), ]);} // ManagerPanelProvider.phppublic 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
PanicDevs — Your panic’s solution 🔥
We’re a developer-focused agency passionate about crafting high-quality Laravel, Filament, and modular solutions. From rapid prototyping to production-ready packages, our mission is to turn your “panic moments” into smooth, scalable, and maintainable code.