alizharb / filament-themes-manager
Advanced theme management system for Laravel Filament with Sushi-powered in-memory storage
Requires
- php: ^8.2|^8.3|^8.4
- calebporzio/sushi: ^2.5
- filament/filament: ^4.0
- illuminate/contracts: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- laravel/framework: ^11.0|^12.0
- qirolab/laravel-themer: ^2.0
Requires (Dev)
- larastan/larastan: ^2.9|^3.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1|^2.0
- phpstan/phpstan-phpunit: ^1.3|^2.0
- phpunit/phpunit: ^11.0|^12.0
- rector/rector: ^1.0
README
A comprehensive, enterprise-grade theme management system for Laravel Filament applications.
Built to seamlessly integrate with qirolab/laravel-themer
, this package provides a sophisticated admin interface for managing, installing, previewing, and switching themes with professional-grade security and performance optimization.
๐ Key Features
Theme Management
- Multi-source Installation - Deploy themes from ZIP files, GitHub repositories, or local directories
- Advanced Cloning System - Duplicate and customize existing themes with intelligent inheritance
- One-Click Activation - Seamlessly switch between themes without downtime
- Safe Deletion - Remove themes with built-in protection for critical system themes
- Live Preview - Test themes in isolation without affecting other users
Security & Validation
- Structure Validation - Comprehensive theme integrity checking
- File Type Restrictions - Configurable security policies for theme uploads
- Protected Themes - Safeguard critical themes from accidental deletion
- Compatibility Checking - Automatic PHP/Laravel version validation
- Malicious Code Scanning - Optional security scanning for theme files
Developer Experience
- Artisan CLI Integration - Full command-line theme management
- Comprehensive API - Programmatic theme operations
- Event System - Custom integrations and workflows
- Multi-language Support - Extensive internationalization
- Cache Optimization - Performance-tuned with intelligent caching
Analytics & Monitoring
- Usage Analytics - Detailed theme performance metrics
- Health Monitoring - Real-time validation status tracking
- Statistics Dashboard - Comprehensive overview widgets
- Asset Compilation - Build status and asset management
๐ System Requirements
Component | Version |
---|---|
PHP | ^8.2|^8.3|^8.4 |
Laravel | ^11.0|^12.0 |
Filament | ^4.0 |
Laravel Themer | ^2.0 |
โก Quick Installation
1. Install Package
composer require alizharb/filament-themes-manager
2. Publish Configuration
php artisan vendor:publish --tag=filament-themes-manager-config
3. Register Plugin
Add to your Filament panel in app/Providers/Filament/AdminPanelProvider.php
:
use Alizharb\FilamentThemesManager\FilamentThemesManagerPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentThemesManagerPlugin::make(), ]); }
4. Enable Preview System (Optional)
Add middleware to bootstrap/app.php
:
->withMiddleware(function (Middleware $middleware) { $middleware->web(append: [ \Alizharb\FilamentThemesManager\Http\Middleware\ThemePreviewMiddleware::class, ]); })
๐ฏ Usage Guide
Admin Interface
Access the theme management interface at System โ Theme Manager in your Filament admin panel.
Core Operations
Action | Description | Access |
---|---|---|
View Details | Inspect theme configuration and metadata | Eye icon |
Activate Theme | Switch active theme instantly | Status toggle |
Preview Theme | Test theme safely in session | Preview button |
Clone Theme | Duplicate theme for customization | Clone action |
Delete Theme | Remove unused themes safely | Delete button |
Bulk Operations
- Multi-select themes using checkboxes
- Bulk deletion of compatible themes
- Configuration export for backup and migration
Command Line Interface
GitHub Installation
php artisan theme:install username/repository --type=github --activate
ZIP Installation
php artisan theme:install /path/to/theme.zip --type=zip
Theme Cloning
php artisan theme:clone default "Custom Default" --slug=custom-default --activate
๐๏ธ Theme Structure
Required Directory Layout
themes/my-theme/
โโโ theme.json # Theme manifest (required)
โโโ views/ # Blade templates
โ โโโ components/ # Reusable components
โ โโโ layouts/ # Page layouts
โโโ css/
โ โโโ app.css # Stylesheets
โโโ js/
โ โโโ app.js # JavaScript assets
โโโ vite.config.js # Build configuration
โโโ screenshot.png # Preview image
Theme Manifest (theme.json)
{ "name": "Professional Theme", "slug": "professional-theme", "version": "1.0.0", "description": "A professional theme for Laravel applications", "author": "Your Name", "author_email": "contact@example.com", "homepage": "https://example.com", "screenshot": "screenshot.png", "parent": null, "requirements": { "php": ">=8.3", "laravel": ">=12.0" }, "assets": ["css/app.css", "js/app.js"], "supports": ["responsive", "dark-mode"], "license": "MIT" }
โ๏ธ Configuration
Theme Discovery
'discovery' => [ 'paths' => [ 'themes' => base_path('themes'), 'resources' => resource_path('themes'), ], 'cache_duration' => 3600, 'auto_discover' => true, ],
Security Configuration
'security' => [ 'validate_theme_structure' => true, 'scan_malicious_code' => true, 'protected_themes' => ['default'], 'allowed_file_types' => [ 'php', 'blade.php', 'css', 'scss', 'js', 'vue', 'json' ], ],
Preview System
'preview' => [ 'enabled' => true, 'route_prefix' => 'theme-preview', 'session_duration' => 3600, 'cache_screenshots' => true, ],
Dashboard Widgets
'widgets' => [ 'enabled' => true, 'page' => true, // Theme Manager page 'dashboard' => true, // Main dashboard ],
๐จ Live Preview System
Capabilities
- Session Isolation - Preview affects only current user
- Professional UI - Elegant banner with intuitive controls
- One-Click Activation - Seamless transition to permanent theme
- Auto-Expiration - Automatic fallback to original theme
- Keyboard Shortcuts -
Ctrl+H
to toggle banner visibility
Preview Routes
Route | Purpose |
---|---|
/theme-preview/{slug} |
Activate preview |
/theme-preview/exit |
Exit preview mode |
/theme-preview/{slug}/activate |
Make preview permanent |
๐ง API Reference
Theme Manager Service
use Alizharb\FilamentThemesManager\Services\ThemeManagerService; $service = app(ThemeManagerService::class); // Theme operations $themes = $service->getAllThemes(); $service->setActiveTheme('theme-slug'); $service->installThemeFromGitHub('username/repository'); $service->cloneTheme('source-slug', 'new-slug', 'New Theme Name'); // Analytics $stats = $service->getThemeStats();
Theme Model
use Alizharb\FilamentThemesManager\Models\Theme; // Queries $themes = Theme::all(); $activeThemes = Theme::active()->get(); $validThemes = Theme::valid()->get(); $theme = Theme::bySlug('theme-slug')->first(); // Statistics $totalCount = Theme::count(); $activeCount = Theme::getActiveCount(); $validCount = Theme::getValidCount();
๐ Troubleshooting
Common Issues
Themes Not Appearing
- Check Permissions: Verify themes directory is readable
- Validate JSON: Ensure
theme.json
files contain valid JSON - Clear Cache: Run
php artisan cache:clear
Preview System Issues
- Middleware Registration: Confirm middleware is properly registered
- Route Accessibility: Verify preview routes are accessible
- Session Configuration: Check session driver and configuration
Asset Loading Problems
- Vite Configuration: Verify theme's Vite setup is correct
- Asset Paths: Ensure paths in
theme.json
are accurate - Build Process: Run
npm run build
for production assets
Debug Configuration
'debug' => env('THEME_DEBUG', false),
Performance Optimization
- Enable theme caching in production environments
- Configure appropriate cache durations
- Utilize asset compilation for faster loading
๐งช Development
Contributing Guidelines
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open Pull Request
Testing Suite
composer test # Run test suite vendor/bin/pest # Run Pest tests directly vendor/bin/pest --coverage # Generate coverage report vendor/bin/phpstan analyse # Static analysis
Code Quality
vendor/bin/pint # Fix code style vendor/bin/rector process # Code modernization
๐ License
This package is open-sourced software licensed under the MIT License. See LICENSE.md for details.
๐ Credits
Core Contributors
- Ali Harb - Lead Developer & Maintainer
Dependencies
- Filament - Admin panel framework
- qirolab/laravel-themer - Core theming engine
- Laravel - PHP framework foundation
๐ Support the Project
Your support helps maintain and improve this package:
- โญ Star the repository
- ๐ Report bugs and issues
- ๐ก Suggest new features
- ๐ Improve documentation
- ๐ฐ Sponsor development
Built with โค๏ธ by Ali Harb
Making Laravel theming professional and accessible