- How do I install Laravel Breadcrumbs in a Laravel project?
- Run `composer require diglactic/laravel-breadcrumbs` to install the package. Then publish the configuration and views with `php artisan vendor:publish --provider="Diglactic\Breadcrumbs\BreadcrumbsServiceProvider"` and add the service provider to `config/app.php`. Follow the README for Laravel version-specific setup.
- Can I use this package with Laravel 13 or the latest version?
- Yes, the package supports Laravel 7–13. Check the [compatibility chart](https://github.com/diglactic/laravel-breadcrumbs#compatibility-chart) for exact version mappings. For Laravel 13, use version 10.x of the package, which is actively maintained and tested.
- How do I define breadcrumbs for a specific route?
- Use the `Breadcrumbs::add()` method in a route closure or controller. For example, `Breadcrumbs::add('Home', route('home'))->parent('Dashboard', route('dashboard'));` to nest breadcrumbs. Define them in a central location like `routes/breadcrumbs.php` for consistency.
- Does Laravel Breadcrumbs support dynamic breadcrumbs (e.g., based on user roles or database data)?
- Yes, you can pass closures to `Breadcrumbs::add()` to dynamically generate crumbs. For example, `Breadcrumbs::add('User Profile', function () { return User::find(Auth::id())->name; })`. This works well for Eloquent models or session-based data, but complex logic may require caching.
- How do I customize the breadcrumb template or output format?
- Publish the default templates with `php artisan vendor:publish --tag=breadcrumbs.views` and modify them in `resources/views/vendor/breadcrumbs/`. You can also create custom templates by extending the base classes or overriding the `render()` method in your own view files.
- Is there built-in support for JSON-LD structured data for SEO?
- Yes, the package includes built-in JSON-LD support for breadcrumbs. Enable it by adding `'jsonld' => true` to the config and the structured data will be automatically injected into your Blade templates. This improves search engine visibility without requiring additional libraries.
- Will this package work with Livewire, Inertia.js, or headless frontend setups?
- The package is Blade-centric and works best for server-rendered views. For Livewire or Inertia.js, you’ll need to manually sync breadcrumbs with client-side state (e.g., using Alpine.js or custom JavaScript). Consider caching breadcrumb data in the session or API responses for headless setups.
- How do I handle breadcrumbs for multi-tenant applications?
- Use middleware or service providers to inject tenant-specific data into breadcrumb closures. For example, bind the tenant ID to the request and access it in closures like `Breadcrumbs::add('Tenant Dashboard', function () { return Tenant::find(Request::tenantId())->name; })`.
- Are there performance concerns with complex breadcrumb hierarchies?
- The package regenerates breadcrumbs on every request, which can impact performance for deeply nested or dynamic trails. Mitigate this by caching trail generation in middleware or using Laravel’s cache system for static segments. Monitor generation time in production to identify bottlenecks.
- What alternatives exist if Laravel Breadcrumbs doesn’t fit my needs?
- Consider `spatie/laravel-breadcrumbs` for a more modern approach with caching and API support, or `orchid/platform` for admin panel-specific breadcrumbs. For lightweight needs, manually render breadcrumbs in Blade using route helpers like `route()` and `back()`. Evaluate based on your stack (e.g., Livewire vs. Blade).