Installation
composer require appdezign/lara-base-theme
Publish the theme assets and configuration:
php artisan vendor:publish --provider="Appdezign\LaraBaseTheme\LaraBaseThemeServiceProvider" --tag="public"
php artisan vendor:publish --provider="Appdezign\LaraBaseTheme\LaraBaseThemeServiceProvider" --tag="config"
First Use Case: Basic Theme Integration
config/cms.php under themes:
'themes' => [
'base' => [
'name' => 'Base Theme',
'path' => base_path('vendor/appdezign/lara-base-theme/resources/views'),
'active' => true,
],
],
@extends('lara-base-theme::layouts.app')
@section('content')
{{ $slot }}
@endsection
Key Files to Review
config/lara-base-theme.php (default config)resources/views/vendor/lara-base-theme/ (default view structure)docs.laracms.nl/ (official documentation)Theme Inheritance
Extend the base theme by creating a custom theme in resources/themes/your-theme:
php artisan vendor:publish --tag="lara-base-theme-views" --provider="Appdezign\LaraBaseTheme\LaraBaseThemeServiceProvider"
Override views by placing them in resources/themes/your-theme/views/.
Dynamic Layouts
Use the @layout directive to switch layouts dynamically:
@layout('lara-base-theme::layouts.admin')
Asset Management Compile assets via Laravel Mix or Vite. The package includes:
resources/sass/)resources/js/)CMS Integration
Leverage Lara CMS components (e.g., @component('cms/page')):
@component('lara-base-theme::components/page-header')
<x-slot name="title">{{ $page->title }}</x-slot>
@endcomponent
@theme to check the active theme:
@theme('base')
<link rel="stylesheet" href="{{ asset('css/base-theme.css') }}">
@endtheme
app/Http/Kernel.php:
protected $middlewareGroups = [
'web' => [
\Appdezign\LaraBaseTheme\Http\Middleware\ThemeMiddleware::class,
],
];
LaraBaseThemeServiceProvider:
public function boot()
{
$this->loadViewsFrom(__DIR__.'/views', 'your-theme');
}
View Path Conflicts
php artisan view:clear if paths aren’t resolving.php artisan view:list
Asset Compilation Issues
vite.config.js includes:
resolve: {
alias: {
'@': path.resolve(__dirname, './resources/js'),
},
},
php artisan cache:clear
npm run dev
Theme Activation
active flag in config/cms.php must match the theme’s slug. Use:
php artisan cms:theme:activate base
Dynamic Content Caching
@cache(false)
{{ $dynamicContent }}
@endcache
EventServiceProvider:
public function boot()
{
event(new \Appdezign\LaraBaseTheme\Events\ThemeActivated($theme));
}
config/lara-base-theme.php for overrides:
'debug' => env('THEME_DEBUG', false), // Enable for verbose logs
@dd() to inspect theme variables:
@dd($this->theme)
Custom Directives
Register new Blade directives in AppServiceProvider:
Blade::directive('themeAsset', function ($path) {
return "<?php echo asset(\"themes/{$path}\"); ?>";
});
Usage:
<img src="{{ themeAsset('images/logo.png') }}">
Theme Hooks Extend the theme system by publishing and overriding hook views:
php artisan vendor:publish --tag="lara-base-theme-hooks"
Example hook in resources/themes/your-theme/hooks/footer.blade.php:
<div class="custom-footer">
{{ $slot }}
</div>
API Integration Use the theme’s API facade to fetch theme data:
use Appdezign\LaraBaseTheme\Facades\Theme;
$themeData = Theme::getActiveTheme();
How can I help you explore Laravel packages today?