@verbatim directives). For API-first apps, themes can be applied via API responses (e.g., Theme::set() in middleware).php artisan view:cache) and asset fingerprinting, reducing runtime overhead.ThemeServiceProvider integrates with Laravel’s trans() helper.| Component | Compatibility | Notes |
|---|---|---|
| Laravel Core | 8.x–11.x (tested) | Uses Laravel’s Service Providers, Middleware, and Blade. |
| Frontend | Blade, Inertia.js, Livewire, Alpine.js | Inertia requires @verbatim directives for theme-specific JS/CSS. |
| Asset Pipeline | Laravel Mix, Vite, Webpack | Themes must follow Laravel’s public path conventions. |
| Database | MySQL, PostgreSQL, SQLite (default) | Custom DB drivers may need adapter layer. |
| Caching | Redis, Memcached, File Cache | Supports tagged caching for theme assets. |
| Auth Systems | Laravel Breeze, Sanctum, Passport, Jetstream | Integrates via middleware (e.g., ThemeMiddleware). |
| Multi-Tenancy | Stancl/Avenger, BeyondCode/Laravel-Permissions | Can extend ThemeServiceProvider to support tenant-aware themes. |
Phase 1: Static Themes
composer require qirolab/laravel-themer.php artisan vendor:publish --provider="Qirolab\Themer\ThemerServiceProvider".config/themer.php (filesystem-based).Kernel.php → append(\Qirolab\Themer\Middleware\ResolveTheme::class).Phase 2: Dynamic Themes
Theme model).Theme::setForUser($user, 'dark-mode')).ThemeResolver.Phase 3: Asset Optimization
Phase 4: Advanced Features
Theme::experiment().@themer directive for theme-aware content.
@themer('dark')
<div class="bg-gray-800">Dark Theme Content</div>
@endthemer
// Inertia response
return Inertia.response(response, {
preserveState: true,
theme: 'dark',
});
public properties to sync theme state.
public $theme = 'light';
Response::macro('withTheme', function ($theme) {
return $this->header('X-Theme', $theme);
});
config('themer.enabled', false).qirolab/laravel-themer for breaking changes (MIT license allows forks if needed).// composer.json
"scripts": {
"themer:update": "php artisan themer:update --path=resources/themes"
}
tailwindcss, bootstrap) via composer workspaces or monorepo.php artisan themer:list → List all available themes.php artisan themer:clear-cache → Invalidate theme cache.Qirolab\Themer\Events\ThemeResolved for runtime debugging.public_path() and mix-manifest.json.ResolveTheme runs after auth middleware.php artisan cache:clear and php artisan view:clear.ThemeResolver output in Redis.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Theme assets missing | Broken UI | Fallback |
How can I help you explore Laravel packages today?