Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Base Laravel Package

rawilk/laravel-base

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. 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).

  2. 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.

  3. 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.).

Implementation Patterns

Common Workflows

  1. 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
    
  2. 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])
    
  3. Meta Tags Pass dynamic meta data via view composers or Blade:

    @baseMeta(['title' => 'Custom Page Title', 'description' => 'Custom description'])
    
  4. Authentication Views Use the package’s auth components (if not using Fortify/Jetstream):

    @auth
        @baseUserDropdown
    @else
        @baseAuthLinks
    @endauth
    

Integration Tips

  • Customize Assets: Override CSS/JS in public/vendor/laravel-base by publishing assets:
    php artisan vendor:publish --tag="laravel-base-assets"
    
  • Partial Overrides: Extend Blade components by copying them from vendor/rawilk/laravel-base/resources/views to your app’s resources/views/vendor/laravel-base.
  • Service Provider: Register custom views or macros in your app’s AppServiceProvider:
    use Rawilk\LaravelBase\Facades\Base;
    
    Base::macro('customComponent', function () {
        // Logic
    });
    

Gotchas and Tips

Pitfalls

  1. Fortify/Jetstream Conflict

    • The package includes auth components (e.g., @baseAuthLinks). If using Fortify/Jetstream, disable these features in config/laravel-base.php:
      'auth' => [
          'enabled' => false,
      ],
      
    • Or manually remove conflicting Blade directives.
  2. Layout Overrides

    • If @base doesn’t render as expected, ensure your layout extends laravel-base::layouts.base and includes @section('content').
    • Debug by checking if the package’s views are published:
      php artisan vendor:publish --tag="laravel-base-views"
      
  3. Dynamic Data Binding

    • The package relies on config arrays for navigation/meta tags. For dynamic data (e.g., user-specific nav items), use view composers or pass data via Blade:
      @baseNav(['items' => $userNavItems])
      
  4. Asset Loading

    • Published assets (CSS/JS) may conflict with your app’s assets. Use unique class names or override the entire asset pipeline.

Debugging

  • Check Published Views: Verify if views are published to resources/views/vendor/laravel-base.
  • Config Validation: Ensure config/laravel-base.php is properly merged (run php artisan config:clear if needed).
  • Blade Directives: Use @dump(Base::config()) to inspect the package’s runtime config.

Extension Points

  1. 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);
    
  2. Macros Add custom Blade macros for reusable logic:

    Blade::macro('baseAlert', function ($type, $message) {
        return Base::alert($type, $message);
    });
    
  3. 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,
    ];
    

Tips

  • Partial Adoption: Use only the components you need (e.g., @baseNav without @base).
  • Testing: Test Blade components in isolation using Laravel’s Blade::render():
    $navHtml = Blade::render('@baseNav', ['items' => []]);
    
  • Fallbacks: Provide fallback content for optional components:
    @baseNav
    @else
        <nav>Fallback Navigation</nav>
    @endbaseNav
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai