alizharb / laravel-themer
Bridge package connecting hexadog/laravel-themes-manager with Livewire 4 and nwidart/laravel-modules
Fund package maintenance!
alizharb
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/alizharb/laravel-themer
Requires
- php: ^8.3
- hexadog/laravel-themes-manager: ^1.14
- illuminate/support: ^12.0
- livewire/livewire: ^4.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/phpstan: ^2.0
Suggests
- alizharb/livewire-modular: For module + theme + Livewire integration
- nwidart/laravel-modules: Required if using livewire-modular
README
Bridge package connecting hexadog/laravel-themes-manager with Livewire 4 and nwidart/laravel-modules.
This package makes hexadog/laravel-themes-manager work seamlessly with Livewire 4 components and nwidart/laravel-modules Blade views, providing theme-aware component resolution and preventing namespace collisions.
Features
- ✅ Livewire 4 Theme Integration: Create and resolve Livewire components in themes
- ✅ Module Theme Support: Override module Blade views with theme-specific versions
- ✅ Namespace Collision Prevention: Separate namespaces for modules (
blog::) and themes (theme-admin::) - ✅ Extended Make Command:
make:livewire --theme=adminfor easy component creation - ✅ Works with livewire-modular: Full compatibility when both packages are installed
- ✅ Non-Breaking: Extends existing finders without breaking Livewire or Laravel functionality
Requirements
- PHP 8.3 or higher
- Laravel 12.0 or higher
- Livewire 4.0 or higher
- hexadog/laravel-themes-manager 3.0 or higher
Installation
composer require alizharb/laravel-themer
The package will automatically register its service provider.
Usage
Creating Livewire Components in Themes
# Create single-file component in theme php artisan make:livewire Header --theme=admin --sfc # Create multi-file component in theme php artisan make:livewire UserMenu --theme=admin --mfc # Create page component in theme php artisan make:livewire pages::dashboard --theme=admin --sfc # Works with livewire-modular (if installed) php artisan make:livewire PostEditor --module=Blog --theme=admin
Using Theme Components in Blade
{{-- Livewire component in theme --}} <livewire:admin::header /> {{-- Page component in theme --}} <livewire:admin::pages::dashboard />
Module Views with Theme Overrides
{{-- Module view (auto theme-aware) --}} @include('blog::posts.index') {{-- Resolves to: Modules/Blog/Themes/admin/resources/views/posts/index.blade.php (if theme active) --}} {{-- Explicit theme view --}} @include('theme-admin::layouts.app') {{-- Resolves to: themes/admin/resources/views/layouts/app.blade.php --}}
Using WithTheme Trait
<?php use AlizHarb\Themer\Concerns\WithTheme; use Livewire\Component; class Dashboard extends Component { use WithTheme; public function render() { return view($this->themedView('dashboard')) ->layout($this->themedView('layouts.app')); } }
How It Works
Component Resolution Priority
Livewire Components:
themes/{theme}/livewire/{component}(theme-specific)app/Livewire/{component}(Livewire default)
With livewire-modular installed:
Modules/{Module}/Themes/{Theme}/livewire/(module theme override)themes/{Theme}/livewire/(theme)Modules/{Module}/Livewire/(module)app/Livewire/(app)
Blade Views:
Modules/{Module}/Themes/{Theme}/resources/views/{view}(module theme override)themes/{Theme}/resources/views/modules/{module}/{view}(theme module override)themes/{Theme}/resources/views/{view}(theme default)Modules/{Module}/resources/views/{view}(module default)resources/views/{view}(Laravel default)
Namespace Collision Prevention
- Modules:
blog::posts.index(no prefix) - Themes (Blade):
theme-admin::layouts.app(prefixed withtheme-) - Themes (Livewire):
admin::header(no prefix, different resolution system)
This prevents conflicts when a module and theme have the same name.
Directory Structure
your-app/
├── themes/
│ └── admin/ # hexadog theme
│ ├── resources/
│ │ └── views/
│ │ ├── layouts/
│ │ └── modules/ # Module view overrides
│ │ └── blog/
│ └── livewire/ # Theme Livewire components
│ ├── Header.php
│ └── Footer.php
├── Modules/ # nwidart modules
│ └── Blog/
│ ├── Livewire/
│ │ └── PostList.php
│ ├── Themes/ # Module theme overrides
│ │ └── admin/
│ │ ├── resources/views/
│ │ └── livewire/
│ └── resources/views/
└── app/
└── Livewire/
Integration with Other Packages
hexadog/laravel-themes-manager
This package extends hexadog's theme system to work with Livewire 4 and modules. All hexadog features continue to work normally.
alizharb/livewire-modular
When both packages are installed, you get full module + theme + Livewire integration:
# Create component in module theme
php artisan make:livewire PostEditor --module=Blog --theme=admin
Resolution priority becomes: Module Theme → Theme → Module → App
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
