codersfree/laratheme
Laratheme es un paquete para Laravel 11/12 que permite gestionar múltiples temas visuales. Cambia el tema activo por configuración, carga vistas con namespace automático y genera nuevos temas con php artisan make:theme. Incluye soporte para assets y stubs publicables.
resources/themes/{theme-name}), which fits microservice-like theme management if combined with asset pipelines (e.g., Laravel Mix/Vite).ThemeMiddleware), which must be registered in app/Http/Kernel.php.@extends and @section, requiring consistent Blade template structure in the base app.| Risk Area | Impact | Mitigation |
|---|---|---|
| Asset Management | Manual theme asset handling (CSS/JS) could lead to duplication or 404s. | Enforce a standardized theme asset structure (e.g., public/themes/{name}/). |
| Theme Switching Logic | Session/cookie-based theming may conflict with API-first apps (e.g., mobile). | Extend to user model attributes or API request headers for consistency. |
| Performance Overhead | Multiple theme checks in middleware could slow requests if misconfigured. | Cache theme resolution (e.g., Cache::remember). |
| Version Compatibility | Laravel 8+ only; no PHP 8.2+ testing. | Test with Laravel 10 + PHP 8.2 in staging. |
| Limited Documentation | No examples for complex theming (e.g., dynamic theme switching via API). | Build an internal runbook with edge cases (e.g., theme fallback logic). |
Theme Switching Mechanism:
/app?theme=dark)?Asset Pipeline Integration:
Internationalization (i18n) Support:
en-dark, es-light)?Admin Panel Requirements:
Testing Strategy:
| Component | Fit Level | Notes |
|---|---|---|
| Laravel 8+ | ✅ High | Native support for facades, middleware, and Blade. |
| Inertia.js/Vue/React | ⚠️ Medium | Theme assets must be dynamically loaded (e.g., via Vite plugins). |
| Livewire | ⚠️ Medium | Theme changes may require Livewire hook integration for reactivity. |
| API-First (Sanctum) | ❌ Low | Session-based theming conflicts; header-based theming needed. |
| Tailwind CSS | ✅ High | Themes can override Tailwind config per environment. |
| Custom Blade Views | ✅ High | Native support for @extends and @section. |
Phase 1: Proof of Concept (2-3 weeks)
default theme).Phase 2: Multi-Theme Support (2 weeks)
light, dark) with distinct assets.Phase 3: Asset Pipeline (1-2 weeks)
Phase 4: Admin & Scaling (1-2 weeks)
Pre-Integration:
@extends/@section consistency.public/themes/{name}/).Core Integration:
ThemeServiceProvider and middleware.php artisan vendor:publish --tag=laratheme-config).Theme Development:
resources/themes/default).Post-Integration:
ThemeMiddleware./debug-theme route to inspect current theme.Cache::remember to middleware.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Theme directory missing | Broken UI (404s) | Fallback to default theme. |
| CSS/JS asset 404 | Visual regression | Validate asset paths in CI. |
| Middleware conflict | Theme not applied | Test middleware order in Kernel.php. |
| Database connection failure (if DB-backed) | Theme unloadable | Graceful fallback to session-based theming. |
| Cache invalidation issues | Stale theme assets | Versioned asset filenames (e.g., theme.css?v=2). |
How can I help you explore Laravel packages today?