PHPackages                             panicdevs/modulite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. panicdevs/modulite

ActiveLibrary[Caching](/categories/caching)

panicdevs/modulite
==================

Automatic Filament Panel Provider discovery for modular Laravel applications with multi-layer caching and performance optimization

v1.1.0(8mo ago)20200↓100%2[1 PRs](https://github.com/panicdevs/modulite/pulls)MITPHPPHP &gt;=8.2

Since Aug 15Pushed 7mo agoCompare

[ Source](https://github.com/panicdevs/modulite)[ Packagist](https://packagist.org/packages/panicdevs/modulite)[ Docs](https://github.com/panicdevs/modulite)[ GitHub Sponsors](https://github.com/sponsors/panicdevs)[ RSS](/packages/panicdevs-modulite/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Modulite
========

[](#modulite)

**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.

Features
--------

[](#features)

- 🔍 **Automatic Discovery**: Finds Filament panels, resources, pages, and widgets across modules
- ⚡ **Production Optimized**: File-based caching system similar to Laravel's bootstrap cache
- 🏗️ **Modular Support**: Works with both `nwidart/laravel-modules` and `panicdevs/modules`
- 🎯 **Flexible Patterns**: Configurable naming patterns and discovery locations
- 📊 **Performance Insights**: Built-in commands for monitoring and optimization
- 🛡️ **Robust Error Handling**: Graceful failure modes for production environments

Installation
------------

[](#installation)

Install via Composer:

```
composer require panicdevs/modulite
```

Publish the configuration file:

```
php artisan vendor:publish --tag=modulite-config
```

Quick Start
-----------

[](#quick-start)

1. **Install the package** (configuration publishes automatically)
2. **Register the plugin** in your Filament panel providers
3. **Structure your modules** following the expected patterns
4. **Run optimization** for production: `php artisan modulite:cache`

### Panel Registration

[](#panel-registration)

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.

How It Works
------------

[](#how-it-works)

### Discovery Process

[](#discovery-process)

Modulite works on two levels:

1. **Panel Providers**: Automatically discovered and registered by the service provider
2. **Components**: Discovered by the plugin for specific panels
    - **Resources**: Filament resource classes for CRUD operations
    - **Pages**: Custom Filament pages
    - **Widgets**: Dashboard widgets and components

### Module Structure

[](#module-structure)

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

```

### Registration Flow

[](#registration-flow)

1. **Bootstrap**: Service provider registers core services during Laravel boot
2. **Panel Discovery**: Panel providers are automatically discovered and registered
3. **Plugin Registration**: `ModulitePlugin` is registered with specific panels for component discovery
4. **Component Discovery**: When panel loads, plugin discovers components (resources, pages, widgets)
5. **Cache Check**: Fast path checks cache file first (per panel)
6. **Scan &amp; Cache**: On cache miss, scans filesystem and caches results
7. **Component Registration**: Discovered components auto-register to the specific panel

Configuration
-------------

[](#configuration)

### Cache Settings

[](#cache-settings)

Configure 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)

### Discovery Locations

[](#discovery-locations)

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`)

### Validation Rules

[](#validation-rules)

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 inheritance
- `allow_custom_base_classes => false`: Only allows direct Filament class inheritance
- Use strict settings for large teams to enforce conventions

### Module Integration

[](#module-integration)

Choose your module management approach:

```
'modules' => [
    'approach' => env('MODULITE_APPROACH', 'panicdevs'), // or 'nwidart'
    'scan_only_enabled' => true,
    'respect_module_priority' => true,
],
```

### Performance Optimization

[](#performance-optimization)

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,
    ],
],
```

Environment Variables
---------------------

[](#environment-variables)

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
```

Production Setup
----------------

[](#production-setup)

### Optimization Commands

[](#optimization-commands)

```
# 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
```

### Deployment Workflow

[](#deployment-workflow)

1. **Build Assets**: Run your normal build process
2. **Cache Application**: `php artisan optimize`
3. **Cache Modulite**: `php artisan modulite:cache`
4. **Deploy**: Your cached discoveries are ready

### Cache Management

[](#cache-management)

The 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
```

Troubleshooting
---------------

[](#troubleshooting)

### Check Discovery Status

[](#check-discovery-status)

```
php artisan modulite:status
```

This shows:

- Configuration summary
- Module status
- Discovered panels and components
- Cache statistics

### Common Issues

[](#common-issues)

**No panels discovered:**

- Check module structure matches expected patterns
- Verify panel classes extend `PanelProvider`
- Check if modules are enabled

**Performance issues:**

- Enable caching: `MODULITE_CACHE_ENABLED=true`
- Set TTL to 0 for production: `MODULITE_CACHE_TTL=0`
- Run `php artisan modulite:cache`

**Components not showing:**

- Verify directory structure matches panel patterns
- Check component naming (must end with `Resource`, `Page`, `Widget`)
- Ensure components extend proper Filament base classes

### Debug Mode

[](#debug-mode)

Enable detailed logging in development:

```
MODULITE_LOGGING_ENABLED=true
MODULITE_LOG_LEVEL=debug
```

### Cache Issues

[](#cache-issues)

Clear all caches if you encounter stale data:

```
php artisan modulite:cache --force
php artisan optimize:clear
```

Performance
-----------

[](#performance)

### Benchmarks

[](#benchmarks)

- **Cold start** (no cache): ~1-20ms depending on module count
- **Warm cache**: ~1-2ms (file include time)
- **Laravel response overhead**: &lt;1ms when optimized

### Production Optimizations

[](#production-optimizations)

Modulite automatically optimizes for production:

- Static caching eliminates repeated file reads
- Lazy discovery defers scanning until needed
- Single cache file minimizes I/O operations
- TTL of 0 prevents unnecessary expiration checks

Advanced Usage
--------------

[](#advanced-usage)

### Custom Base Classes

[](#custom-base-classes)

You can use custom base classes for components:

```
'components' => [
    'types' => [
        'resources' => [
            'allow_custom_base_classes' => true,
            'strict_inheritance' => false,
        ],
    ],
],
```

### Manual Component Registration

[](#manual-component-registration)

For edge cases, disable auto-discovery and register manually:

```
'components' => [
    'registration' => [
        'auto_register' => false,
    ],
],
```

### Multiple Panel Support

[](#multiple-panel-support)

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

```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Filament 4.0+

Support
-------

[](#support)

- 📖 [Documentation](https://github.com/panicdevs/modulite#readme)
- 🐛 [Issues](https://github.com/panicdevs/modulite/issues)

---

**Made with ❤️ by [PanicDevs](https://github.com/panicdevs)**

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

3

Last Release

247d ago

Major Versions

v0.1 → v1.0.02025-09-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa4e842e5598f28c0f3957b7ce6cc82391db11ca7117c57bcab18955f5243d48?d=identicon)[RealMrHex](/maintainers/RealMrHex)

---

Top Contributors

[![RealMrHex](https://avatars.githubusercontent.com/u/62525184?v=4)](https://github.com/RealMrHex "RealMrHex (6 commits)")[![mra9994](https://avatars.githubusercontent.com/u/45072886?v=4)](https://github.com/mra9994 "mra9994 (1 commits)")

---

Tags

filamentlaravelmodularpanicdevslaravelperformancecachingdiscoverymodulesnwidartmodularfilamentpanelspanicdevs

### Embed Badge

![Health badge](/badges/panicdevs-modulite/health.svg)

```
[![Health](https://phpackages.com/badges/panicdevs-modulite/health.svg)](https://phpackages.com/packages/panicdevs-modulite)
```

###  Alternatives

[maartenstaa/laravel-41-route-caching

This package allows you to cache your routes definitions, thereby speeding up each request.

25371.9k](/packages/maartenstaa-laravel-41-route-caching)[moox/jobs

Manage Job Queues, Failed Jobs and Batches in Filament.

6421.8k](/packages/moox-jobs)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
