PHP code example of panicdevs / modulite
1. Go to this page and download the library: Download panicdevs/modulite library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
panicdevs / modulite example snippets
// 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
}
'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(),
],
'panels' => [
'locations' => [
'modules/*/Providers/Filament/Panels',
'foundation/*/Providers/Filament/Panels',
],
],
'components' => [
'locations' => [
'modules/*/Filament/{panel}/Resources',
'modules/*/Filament/{panel}/Pages',
'modules/*/Filament/{panel}/Widgets',
],
],
'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),
],
],
'modules' => [
'approach' => env('MODULITE_APPROACH', 'panicdevs'), // or 'nwidart'
'scan_only_enabled' => true,
'respect_module_priority' => true,
],
'performance' => [
'lazy_discovery' => env('MODULITE_LAZY_DISCOVERY', true),
'memory_optimization' => [
'batch_size' => 100,
'clear_stat_cache' => true,
'gc_after_scan' => true,
],
],
'components' => [
'types' => [
'resources' => [
'allow_custom_base_classes' => true,
'strict_inheritance' => false,
],
],
],
'components' => [
'registration' => [
'auto_register' => false,
],
],
// 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(),
]);
}
bash
php artisan vendor:publish --tag=modulite-config
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
bash
# Cache file location
bootstrap/cache/modulite.php
# Clear with Laravel caches
php artisan optimize:clear
# Or clear specifically
php artisan modulite:cache --force
bash
php artisan modulite:status
bash
MODULITE_LOGGING_ENABLED=true
MODULITE_LOG_LEVEL=debug
bash
php artisan modulite:cache --force
php artisan optimize:clear
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