A hacky way you could do it would be to use something like:
config(['view.paths' => [resource_path('views/my_theme')]]);
Maybe in a middleware configured in your routes? No idea about the vite configuration side though.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i want to create a laravel theme package that will load views based on selected theme in theme config file, such that if selected theme is shop, return view('home.index) will automatically load view in resources/views/shop/home/index.blade.php, likewise if mart it'll load views from resources/views/mart folder. this is what i have so far:
ThemeViewFinder.php
<?php
namespace Vendora\Theme;
use Illuminate\View\FileViewFinder;
class ThemeViewFinder extends FileViewFinder
{
// DON'T KNOW WHAT TO DO
}
ThemeServiceProvider.php
<?php
namespace Vendora\Theme\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class ThemeServiceProvider extends ServiceProvider
{
public function boot()
{
// WHAT TO DO
}
public function register()
{
// WHAT TO DO
}
}
themes.php config file
<?php
return [
'default' => 'shop',
'themes' => [
'shop' => [
'name' => 'Default Shop Theme',
'assets_path' => 'public/themes/shop/assets',
'views_path' => 'resources/views/shop',
'vite' => [
'hot_file' => 'shop-default-vite.hot',
'build_directory' => 'themes/shop/default/build',
'package_assets_directory' => 'resources/shop',
],
],
],
'admin-default' => 'shop-admin',
'admin-themes' => [
'shop-admin' => [
'name' => 'Default Shop Admin Theme',
'assets_path' => 'public/themes/shop-admin/default',
'views_path' => 'resources/views/shop-admin',
'vite' => [
'hot_file' => 'shop-admin-default-vite.hot',
'build_directory' => 'themes/shop-admin/default/build',
'package_assets_directory' => 'resources/shop',
],
],
],
];
any help? not an expert in laravel...
Please or to participate in this conversation.