Installation
composer require rawilk/laravel-base
php artisan vendor:publish --provider="Rawilk\LaravelBase\LaravelBaseServiceProvider"
Publish the config file to customize default settings (e.g., config/laravel-base.php).
First Use Case
Use the base Blade directive to include the package’s default layout:
@base
This renders the package’s default layout (if configured) with common UI elements like navigation, footer, and meta tags.
Key Components
@base: Renders the default layout.@baseNav: Generates a responsive navigation bar.@baseFooter: Adds a footer section.@baseMeta: Injects SEO meta tags (title, description, etc.).Layout Integration
Extend the package’s layout in your app’s resources/views/layouts/app.blade.php:
@extends('laravel-base::layouts.base')
@section('content')
{{ $slot }}
@endsection
Dynamic Navigation
Override the navigation in config/laravel-base.php:
'nav' => [
'items' => [
['url' => '/', 'label' => 'Home'],
['url' => '/about', 'label' => 'About'],
],
],
Or use Blade components:
@baseNav(['items' => $customNavItems])
Meta Tags Pass dynamic meta data via view composers or Blade:
@baseMeta(['title' => 'Custom Page Title', 'description' => 'Custom description'])
Authentication Views Use the package’s auth components (if not using Fortify/Jetstream):
@auth
@baseUserDropdown
@else
@baseAuthLinks
@endauth
public/vendor/laravel-base by publishing assets:
php artisan vendor:publish --tag="laravel-base-assets"
vendor/rawilk/laravel-base/resources/views to your app’s resources/views/vendor/laravel-base.AppServiceProvider:
use Rawilk\LaravelBase\Facades\Base;
Base::macro('customComponent', function () {
// Logic
});
Fortify/Jetstream Conflict
@baseAuthLinks). If using Fortify/Jetstream, disable these features in config/laravel-base.php:
'auth' => [
'enabled' => false,
],
Layout Overrides
@base doesn’t render as expected, ensure your layout extends laravel-base::layouts.base and includes @section('content').php artisan vendor:publish --tag="laravel-base-views"
Dynamic Data Binding
@baseNav(['items' => $userNavItems])
Asset Loading
resources/views/vendor/laravel-base.config/laravel-base.php is properly merged (run php artisan config:clear if needed).@dump(Base::config()) to inspect the package’s runtime config.Custom Components
Extend the package by creating new Blade components in app/View/Components and register them in AppServiceProvider:
Base::component('customComponent', \App\View\Components\CustomComponent::class);
Macros Add custom Blade macros for reusable logic:
Blade::macro('baseAlert', function ($type, $message) {
return Base::alert($type, $message);
});
Middleware
Use the package’s middleware (e.g., Base\Middleware\CheckAuth) by adding it to your kernel.php:
protected $middleware = [
// ...
\Rawilk\LaravelBase\Middleware\CheckAuth::class,
];
@baseNav without @base).Blade::render():
$navHtml = Blade::render('@baseNav', ['items' => []]);
@baseNav
@else
<nav>Fallback Navigation</nav>
@endbaseNav
How can I help you explore Laravel packages today?