facuz/laravel-themes
A Laravel package for adding multi-theme support to your app. Organize theme views, assets, translations, and configuration, switch the active theme at runtime, and use theme-aware Blade helpers without changing your core application structure.
facuz/laravel-themes with Composer, then publish the package config/provider assets (php artisan vendor:publish). On Laravel 5.5+ the service provider and Theme facade are usually auto-discovered; on older versions add them to config/app.php.config/theme.php first. This is where the theme root and public asset path are defined. Confirm those paths match where you intend to keep themes; everything else in the package is driven from them.themes/default/views/layouts/app.blade.phpthemes/default/views/home.blade.phpthemes/default/views/partials/header.blade.phpthemes/default/assets/css/app.cssAppServiceProvider::boot() or a simple middleware call Theme::set('default'). This is the package’s core switch; views, partials and asset resolution then follow that active theme.return Theme::view('home'); rather than view('home'). That is the first end-to-end use case: request → theme selection → layout/partial rendering → asset tags.Theme::asset()->add('app', 'css/app.css'), then output {!! Theme::asset()->styles() !!} and {!! Theme::asset()->scripts() !!} in the layout. Partials are rendered with Theme::partial('header') so they resolve against the active theme.Theme::exists(), then call Theme::set(). This keeps every controller unaware of the active theme.layouts/app.blade.php) and standard partial names (header, footer, nav, sidebar). Controllers and routes then call Theme::view('page'), while the layout handles Theme::partial() and asset rendering. This keeps theme differences isolated to view files.Theme::asset()->container('footer')->add('app-js', 'js/app.js', ['jquery']). Use dependency arrays for ordering and unique asset names to avoid silent overwrites. Render each container exactly once in the layout.domain => theme or plan => theme map in your own config, then resolve it in middleware. This is more maintainable than scattering Theme::set() calls through controllers.Theme::view() in a base controller method (protected function themeView($name, $data = [])) so you can add analytics, shared view data, or fallback logic in one place.setUp() or via the middleware under test, then assert the rendered view and asset output. Use View::getName() or response assertions to confirm the correct theme view was selected.public/themes to the source theme assets avoids repeated copying.teepluss/theme and targets older Laravel conventions. Check its Composer constraints against your Laravel version before adopting it; on modern Laravel you may need a fork or a shim for removed helpers.Theme:: is undefined, the provider or Theme alias is missing from config/app.php.php artisan config:cache evaluates base_path()/public_path() once. Avoid env() inside config/theme.php; after changing theme paths run php artisan config:clear and recache.php artisan view:clear. A stale compiled view is a common cause of “my new theme file is ignored.”asset() URLs into Theme::asset()->add() produces duplicated or broken paths.theme-app-css, vendor-jquery) and verify dependency order in the rendered output; a missing dependency can prevent a script from appearing.Theme::set() is effectively global for the request. In long-running workers (Octane, Swoole) reset the theme at the start or end of each request in middleware, otherwise one request’s theme can bleed into the next.Theme::all()/Theme::exists() and reject path separators.Theme::set() inside a view composer or after a view has begun rendering is too late; resolve it in middleware or a service provider boot path.How can I help you explore Laravel packages today?