### Install Modulite Package (Bash) Source: https://github.com/panicdevs/modulite/blob/develop/README.md Installs the Modulite package using Composer. This is the initial step to integrate Modulite into your Laravel project. ```bash composer require panicdevs/modulite ``` -------------------------------- ### Modulite Cache Configuration Example (PHP) Source: https://github.com/panicdevs/modulite/blob/develop/README.md Defines the cache settings for Modulite. This configuration controls whether caching is enabled, the cache file location, its time-to-live (TTL), and auto-invalidation behavior. ```php '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(), ] ``` -------------------------------- ### Test Modulite Component Discovery and Cache Management (PHP) Source: https://context7.com/panicdevs/modulite/llms.txt Provides example test cases for verifying Modulite's functionality. It includes tests for discovering components for a specific panel and ensuring the cache manager correctly stores and retrieves data. ```php app->make(ComponentScannerInterface::class); $components = $scanner->discoverComponentsForPanel('admin'); $this->assertArrayHasKey('resources', $components); $this->assertArrayHasKey('pages', $components); $this->assertArrayHasKey('widgets', $components); $this->assertNotEmpty($components['resources']); } public function test_cache_manager_stores_and_retrieves_data(): void { $cache = $this->app->make(CacheManagerInterface::class); $cache->put('test.key', ['data' => 'value']); $retrieved = $cache->get('test.key'); $this->assertEquals(['data' => 'value'], $retrieved); } public function test_plugin_clears_static_caches(): void { ModulitePlugin::clearStaticCaches(); // Verify caches are cleared - subsequent discoveries will scan fresh $scanner = $this->app->make(ComponentScannerInterface::class); $components = $scanner->discoverComponentsForPanel('admin'); $this->assertIsArray($components); } } ``` -------------------------------- ### Register User Resource for Admin Panel using PHP Source: https://context7.com/panicdevs/modulite/llms.txt Demonstrates how to define a Filament Resource for the 'admin' panel. The resource automatically discovers and registers to the 'admin' panel without manual configuration, simplifying integration. ```php discoverComponentsForPanel('admin'); // Returns: [ // 'resources' => ['Modules\User\Filament\Admin\Resources\UserResource', ...], // 'pages' => ['Modules\User\Filament\Admin\Pages\Dashboard', ...], // 'widgets' => ['Modules\User\Filament\Admin\Widgets\StatsWidget', ...] // ] // Discover specific component type $resources = $componentScanner->discoverComponentType('admin', 'resources'); // Returns: ['Modules\User\Filament\Admin\Resources\UserResource', ...] // Validate if a class is a valid component $isValid = $componentScanner->isComponentType( 'Modules\User\Filament\Admin\Resources\UserResource', 'resources' ); // Returns: true // Get scan statistics $stats = $componentScanner->getScanStats(); // Returns: [ // 'scanned_modules' => 5, // 'scanned_files' => 87, // 'found_resources' => 12, // 'found_pages' => 8, // 'found_widgets' => 4, // 'scan_time' => 0.042 // ] // Refresh cache manually $componentScanner->refreshCache(); ``` -------------------------------- ### Publish Modulite Configuration (Artisan CLI) Source: https://context7.com/panicdevs/modulite/llms.txt Publish and customize Modulite's configuration file using the Artisan command-line interface. This command makes the `config/modulite.php` file available for modification, allowing advanced users to tailor discovery locations, patterns, validation rules, and cache settings. ```bash # Publish configuration file php artisan vendor:publish --tag=modulite-config # Creates: config/modulite.php ``` -------------------------------- ### Set Modulite Environment Variables for Configuration Source: https://github.com/panicdevs/modulite/blob/develop/README.md Lists essential environment variables for configuring Modulite, covering cache control, performance settings, validation rules, and debugging. These variables provide an easy way to manage application settings via the .env file. ```bash # 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 ``` -------------------------------- ### Modulite Configuration File Structure (PHP) Source: https://context7.com/panicdevs/modulite/llms.txt The `config/modulite.php` file defines Modulite's behavior, including panel and component discovery locations and patterns, validation rules, cache settings, and module system integration. Customize these settings to match your project's structure and requirements. ```php [ 'locations' => [ 'modules/*/Providers/Filament/Panels', 'foundation/*/Providers/Filament/Panels', ], 'patterns' => [ 'files' => ['*PanelProvider.php', '*Panel.php'], 'classes' => ['*PanelProvider', '*Panel'], ], 'validation' => [ 'strict_inheritance' => false, 'must_extend' => 'Filament\PanelProvider', 'allow_custom_base_classes' => true, ], ], // Configure component discovery locations 'components' => [ 'locations' => [ 'modules/*/Filament/{panel}/Resources', 'modules/*/Filament/{panel}/Pages', 'modules/*/Filament/{panel}/Widgets', ], 'types' => [ 'resources' => ['enabled' => true], 'pages' => ['enabled' => true], 'widgets' => ['enabled' => true], ], ], // Cache configuration 'cache' => [ 'enabled' => env('MODULITE_CACHE_ENABLED', !env('APP_DEBUG', false)), 'file' => base_path('bootstrap/cache/modulite.php'), 'ttl' => env('MODULITE_CACHE_TTL', 0), // 0 = never expires (production) ], // Module system integration 'modules' => [ 'approach' => env('MODULITE_APPROACH', 'panicdevs'), // or 'nwidart' 'scan_only_enabled' => true, ], ]; ``` -------------------------------- ### Manage Modulite Cache with Artisan and Laravel Source: https://github.com/panicdevs/modulite/blob/develop/README.md Demonstrates how to manage Modulite's cache, which functions similarly to Laravel's bootstrap cache. It shows the cache file location and commands to clear caches using both Modulite-specific and general Laravel commands. ```bash # Cache file location bootstrap/cache/modulite.php # Clear with Laravel caches php artisan optimize:clear # Or clear specifically php artisan modulite:cache --force ``` -------------------------------- ### Configure Modulite Module Integration Approach Source: https://github.com/panicdevs/modulite/blob/develop/README.md Specifies the module management approach for Modulite, allowing a choice between 'panicdevs' or 'nwidart'. It also includes options to enable scanning only and respect module priority. This configuration helps manage how modules are integrated and processed. ```php 'modules' => [ 'approach' => env('MODULITE_APPROACH', 'panicdevs'), // or 'nwidart' 'scan_only_enabled' => true, 'respect_module_priority' => true, ], ``` -------------------------------- ### View Modulite Status and Diagnostics Source: https://context7.com/panicdevs/modulite/llms.txt Provides a status report of Modulite, including configuration details, module status, and cache statistics. Options include clearing the cache before showing status (`--clear-cache`), forcing a rescan (`--scan`), and displaying detailed statistics (`--vvv`). ```bash # Basic status report php artisan modulite:status # Clear cache before showing status php artisan modulite:status --clear-cache # Force rescan and show results php artisan modulite:status --scan # Show detailed statistics php artisan modulite:status --vvv # Output example: # Modulite Status Report # =================== # # Configuration: # +------------------+---------------------------------------+ # | Setting | Value | # +------------------+---------------------------------------+ # | Cache Enabled | ✓ | # | Cache File | bootstrap/cache/modulite.php | # | Lazy Discovery | ✓ | # | Logging Enabled | ✗ | # | Fail Silently | ✓ | # +------------------+---------------------------------------+ # # Module Status: # Found 5 enabled modules: # • User # • Blog # • Commerce # • Analytics # • Settings ``` -------------------------------- ### Configure Modulite Performance Optimizations Source: https://github.com/panicdevs/modulite/blob/develop/README.md Sets up performance optimizations for Modulite, focusing on lazy discovery and memory management. It includes configurations for batch size, clearing stat cache, and garbage collection after scanning to improve production performance. ```php 'performance' => [ 'lazy_discovery' => env('MODULITE_LAZY_DISCOVERY', true), 'memory_optimization' => [ 'batch_size' => 100, 'clear_stat_cache' => true, 'gc_after_scan' => true, ], ], ``` -------------------------------- ### Run Modulite Cache and Status Commands Source: https://github.com/panicdevs/modulite/blob/develop/README.md Artisan commands for managing Modulite's cache and status. Includes commands to cache discoveries for production, force cache clearing, check module status, and perform detailed diagnostics. ```bash # 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 ``` -------------------------------- ### Modulite Component Discovery Locations Configuration (PHP) Source: https://github.com/panicdevs/modulite/blob/develop/README.md Defines the directory patterns for discovering Filament components (Resources, Pages, Widgets) within modules, based on the panel ID. Uses placeholders for module names and panel identifiers. ```php 'components' => [ 'locations' => [ 'modules/*/Filament/{panel}/Resources', 'modules/*/Filament/{panel}/Pages', 'modules/*/Filament/{panel}/Widgets', ], ] ``` -------------------------------- ### Integrate Modulite Services in Custom Service Provider (PHP) Source: https://context7.com/panicdevs/modulite/llms.txt Shows how to inject and utilize Modulite's ComponentScannerInterface and CacheManagerInterface within a custom Laravel Service Provider. This allows for custom logic like discovering components and managing their cache. ```php has('custom.discovery')) { $components = $componentScanner->discoverComponentsForPanel('custom'); $cacheManager->put('custom.discovery', $components, 3600); } // Register custom panels discovered from modules $customComponents = $cacheManager->get('custom.discovery', []); foreach ($customComponents['resources'] as $resource) { // Custom registration logic } } } ``` -------------------------------- ### Modulite Environment Variables (.env) Source: https://context7.com/panicdevs/modulite/llms.txt Configure Modulite's behavior through environment variables in your `.env` file. Control cache settings, performance optimizations like lazy discovery and static caching, module system approach, and validation rules for development. ```dotenv # .env configuration # Cache Control MODULITE_CACHE_ENABLED=true MODULITE_CACHE_TTL=0 # Performance MODULITE_LAZY_DISCOVERY=true MODULITE_STATIC_CACHING=true # Module System MODULITE_APPROACH=panicdevs # or 'nwidart' # Validation (development) MODULITE_STRICT_INHERITANCE=false MODULITE_ALLOW_CUSTOM_BASE_CLASSES=true # Debugging (development only) MODULITE_LOGGING_ENABLED=false MODULITE_LOG_LEVEL=info ``` -------------------------------- ### Enable Debug Mode and Logging in Modulite Source: https://github.com/panicdevs/modulite/blob/develop/README.md Configuration to enable detailed logging and debug mode in Modulite during development. Setting `MODULITE_LOGGING_ENABLED` to true and `MODULITE_LOG_LEVEL` to 'debug' provides more insights into application behavior. ```bash MODULITE_LOGGING_ENABLED=true MODULITE_LOG_LEVEL=debug ``` -------------------------------- ### Register ModulitePlugin for Admin and Manager Panels Source: https://github.com/panicdevs/modulite/blob/develop/README.md This code demonstrates how to register the ModulitePlugin within the panel provider for both 'admin' and 'manager' panels. It ensures that Modulite can discover components specific to each panel. ```php // 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(), ]); } ``` -------------------------------- ### Cache Modulite Panels and Components Source: https://context7.com/panicdevs/modulite/llms.txt Generates and caches all discovered Filament panels and components for production deployment. The `--force` option can be used to regenerate existing cache, and `--enable-cache` can temporarily enable caching even in debug mode. The output shows the number of cached items and the cache file location. ```bash # Basic cache generation php artisan modulite:cache # Force regeneration of existing cache php artisan modulite:cache --force # Enable caching temporarily even in debug mode php artisan modulite:cache --enable-cache # Output example: # Optimizing Modulite caches... # • Warming panel discovery cache... # ✓ Found 3 panel providers # • Warming component discovery cache... # - admin: 12 components # - manager: 8 components # - public: 4 components # ✓ Found 24 components # - Cache file: /path/to/bootstrap/cache/modulite.php # - Cache size: 8,432 bytes # Modulite caches optimized successfully! # - 3 panel providers cached # - 24 components cached ``` -------------------------------- ### Organize Filament Components with Modulite Directory Structure Source: https://context7.com/panicdevs/modulite/llms.txt Follows Modulite's expected directory structure for organizing Filament components within modules. This structure separates panel providers from panel-specific resources, pages, and widgets. ```directory modules/ └── User/ ├── Providers/ │ └── Filament/ │ └── Panels/ │ ├── AdminPanelProvider.php # Panel definition │ └── ManagerPanelProvider.php # Another panel │ └── Filament/ ├── Admin/ # Components for 'admin' panel │ ├── Resources/ │ │ ├── UserResource.php │ │ └── RoleResource.php │ ├── Pages/ │ │ ├── UserDashboard.php │ │ └── UserSettings.php │ └── Widgets/ │ ├── UserStatsWidget.php │ └── UserActivityWidget.php │ └── Manager/ # Components for 'manager' panel └── Resources/ └── ProfileResource.php ``` -------------------------------- ### Modulite Panel Discovery Locations Configuration (PHP) Source: https://github.com/panicdevs/modulite/blob/develop/README.md Specifies the file paths where Modulite should search for Filament panel provider definitions within your modules. Supports wildcard and foundation directories. ```php 'panels' => [ 'locations' => [ 'modules/*/Providers/Filament/Panels', 'foundation/*/Providers/Filament/Panels', ], ] ``` -------------------------------- ### Status and Diagnostics Command Source: https://context7.com/panicdevs/modulite/llms.txt View discovery status, cache statistics, and configuration information using the `modulite:status` Artisan command. Options include clearing cache, forcing a rescan, and showing detailed statistics. ```APIDOC ## Status and Diagnostics Command ### Description View discovery status, cache statistics, and configuration information. ### Method Artisan Command ### Endpoint `php artisan modulite:status` ### Parameters #### Query Parameters - **`--clear-cache`** (flag) - Optional - Clear cache before showing status. - **`--scan`** (flag) - Optional - Force rescan and show results. - **`--vvv`** (flag) - Optional - Show detailed statistics. ### Request Example ```bash # Basic status report php artisan modulite:status # Clear cache before showing status php artisan modulite:status --clear-cache # Force rescan and show results php artisan modulite:status --scan # Show detailed statistics php artisan modulite:status --vvv ``` ### Response #### Success Response (Output Example) ``` Modulite Status Report =================== Configuration: +------------------+---------------------------------------+ | Setting | Value | +------------------+---------------------------------------+ | Cache Enabled | ✓ | | Cache File | bootstrap/cache/modulite.php | | Lazy Discovery | ✓ | | Logging Enabled | ✗ | | Fail Silently | ✓ | +------------------+---------------------------------------+ Module Status: Found 5 enabled modules: • User • Blog • Commerce • Analytics • Settings ``` ``` -------------------------------- ### Configure Modulite Component Custom Base Classes Source: https://github.com/panicdevs/modulite/blob/develop/README.md Allows the use of custom base classes for Modulite components, specifically for resources. It enables custom base classes and disables strict inheritance for component types, offering flexibility in component development. ```php 'components' => [ 'types' => [ 'resources' => [ 'allow_custom_base_classes' => true, 'strict_inheritance' => false, ], ], ], ``` -------------------------------- ### Clear Modulite Cache using Artisan Commands (Bash) Source: https://context7.com/panicdevs/modulite/llms.txt Details Artisan commands to manage Modulite caches. Includes specific commands to clear only Modulite caches or all Laravel caches, and a command to check the cache status. ```bash # Clear Modulite cache specifically php artisan modulite:clear # Or clear all Laravel caches (includes Modulite) php artisan optimize:clear # Verify cache cleared php artisan modulite:status # Output will show: # Cache Status: # +---------------+-------+ # | Metric | Value | # +---------------+-------+ # | Enabled | ✓ | # | File Exists | ✗ | # | Total Items | 0 | # +---------------+-------+ ``` -------------------------------- ### Manage Modulite Cache Programmatically (PHP) Source: https://context7.com/panicdevs/modulite/llms.txt Manage Modulite's file-based cache system programmatically using the Cache Manager Service. Store, retrieve, and check for cached data using keys. Utilize the 'remember' pattern to cache the result of a callback. The service also allows for removing specific cache entries, clearing all caches, and retrieving cache statistics and file paths. ```php put('panels:discovery', $panels); // Retrieve cached data $cachedPanels = $cacheManager->get('panels:discovery'); // Returns: ['AdminPanelProvider', 'ManagerPanelProvider'] // Remember pattern - cache result of callback $components = $cacheManager->remember('components.admin', function() { return ['UserResource', 'PostResource', 'CommentResource']; }); // Returns: ['UserResource', 'PostResource', 'CommentResource'] // Check if cache has a key if ($cacheManager->has('components.admin')) { // Cache exists } // Remove specific cache entry $cacheManager->forget('components.admin'); // Clear all caches $cacheManager->flush(); // Get cache statistics $stats = $cacheManager->getStats(); // Returns: [ // 'file_exists' => true, // 'file_size' => 8432, // 'enabled' => true, // 'total_items' => 15, // 'cache_created' => 1704123456, // 'valid_items' => 14, // 'expired_items' => 1 // ] // Get cache file path $filePath = $cacheManager->getCacheFile(); // Returns: '/var/www/bootstrap/cache/modulite.php' ``` -------------------------------- ### Cache Optimization Command Source: https://context7.com/panicdevs/modulite/llms.txt Generate and cache all discovered panels and components for production deployment using the `modulite:cache` Artisan command. Options include forcing regeneration and enabling cache in debug mode. ```APIDOC ## Cache Optimization Command ### Description Generate and cache all discovered panels and components for production deployment. ### Method Artisan Command ### Endpoint `php artisan modulite:cache` ### Parameters #### Query Parameters - **`--force`** (flag) - Optional - Force regeneration of existing cache. - **`--enable-cache`** (flag) - Optional - Enable caching temporarily even in debug mode. ### Request Example ```bash # Basic cache generation php artisan modulite:cache # Force regeneration of existing cache php artisan modulite:cache --force # Enable caching temporarily even in debug mode php artisan modulite:cache --enable-cache ``` ### Response #### Success Response (Output Example) ``` Optimizing Modulite caches... • Warming panel discovery cache... ✓ Found 3 panel providers • Warming component discovery cache... - admin: 12 components - manager: 8 components - public: 4 components ✓ Found 24 components - Cache file: /path/to/bootstrap/cache/modulite.php - Cache size: 8,432 bytes Modulite caches optimized successfully! - 3 panel providers cached - 24 components cached ``` ``` -------------------------------- ### Register Modulite Plugin with Filament Panel Source: https://context7.com/panicdevs/modulite/llms.txt Register the ModulitePlugin within a Filament panel's provider to enable automatic discovery and registration of Filament components across modules. This replaces the need for manual `discoverResources`, `discoverPages`, and `discoverWidgets` calls. ```php default() ->id('admin') ->path('admin') ->login() ->plugins([ ModulitePlugin::make(), // Discovers and registers all components ]) ->colors([ 'primary' => '#3b82f6', ]) ->discoverResources(in: null, for: null) // Can be removed - Modulite handles this ->discoverPages(in: null, for: null) // Can be removed - Modulite handles this ->discoverWidgets(in: null, for: null); // Can be removed - Modulite handles this } } ``` -------------------------------- ### Register ModulitePlugin in Filament Panel Provider (PHP) Source: https://github.com/panicdevs/modulite/blob/develop/README.md Registers the ModulitePlugin within a Filament Panel Provider. This enables Modulite to automatically discover and register Filament components for the specified panel. ```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 } ``` -------------------------------- ### Plugin Registration Source: https://context7.com/panicdevs/modulite/llms.txt Register the ModulitePlugin with a Filament panel to enable automatic component discovery. This process involves adding the plugin to your PanelProvider. ```APIDOC ## Plugin Registration ### Description Register the ModulitePlugin with a Filament panel to enable automatic component discovery. ### Method Not Applicable (Configuration) ### Endpoint Not Applicable (Configuration) ### Parameters Not Applicable ### Request Example ```php default() ->id('admin') ->path('admin') ->login() ->plugins([ ModulitePlugin::make(), // Discovers and registers all components ]) ->colors([ 'primary' => '#3b82f6', ]) ->discoverResources(in: null, for: null) // Can be removed - Modulite handles this ->discoverPages(in: null, for: null) // Can be removed - Modulite handles this ->discoverWidgets(in: null, for: null); // Can be removed - Modulite handles this } } ``` ### Response Not Applicable ``` -------------------------------- ### Configure Validation Rules for Modulite Panels Source: https://github.com/panicdevs/modulite/blob/develop/README.md Defines strictness for discovery validation in Modulite panels. It controls inheritance rules and whether custom base classes are allowed, with options to enforce exact class inheritance or only direct Filament class inheritance. Use strict settings for large teams to enforce conventions. ```php '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), ], ], ``` -------------------------------- ### Disable Modulite Auto-Discovery for Manual Registration Source: https://github.com/panicdevs/modulite/blob/develop/README.md Disables automatic component discovery in Modulite, enabling manual registration for specific use cases. This provides granular control over which components are registered and how. ```php 'components' => [ 'registration' => [ 'auto_register' => false, ], ], ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.