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
Breadcrumbtrail Bundle

Breadcrumbtrail Bundle Laravel Package

apy/breadcrumbtrail-bundle

View on GitHub
Deep Wiki
Context7

Symfony bundle to generate a dynamic Twig breadcrumbs trail via Annotations, PHP Attributes or PHP methods.

Frequently asked questions about Breadcrumbtrail Bundle
Can I use APYBreadcrumbTrailBundle directly in a Laravel project without Symfony?
No, this bundle is Symfony-centric and relies on its DI, Twig, and annotation systems. For Laravel, you’d need to adapt it via PHP Attributes (preferred), Doctrine’s AnnotationReader, or manually parse breadcrumbs in middleware/route filters. Twig integration would require embedding it as a microservice or converting templates to Blade.
How do I migrate breadcrumbs from Symfony annotations to Laravel-compatible PHP Attributes?
Replace `@Breadcrumb` annotations with `[Breadcrumb]` attributes (PHP 8+). Use the bundle’s Attribute-based configuration (documented in `php_configuration.md`). For legacy apps, a custom annotation-to-attribute converter may be needed, but this adds complexity. Test thoroughly—Laravel’s reflection behavior differs slightly from Symfony’s.
What’s the easiest way to render breadcrumbs in Laravel if I’m using Blade instead of Twig?
Extract breadcrumb data via the bundle’s service (bound to Laravel’s container) and render it manually in Blade. Alternatively, use Twig’s `@embed` directive to include Twig-rendered HTML snippets in Blade views. Avoid full Twig integration unless necessary—it introduces overhead and dependency bloat.
Does this bundle support Laravel’s route model binding (e.g., `{user}` in routes) for dynamic breadcrumbs?
No, the bundle assumes Symfony’s controller-based routing. For Laravel, you’d need to manually resolve route parameters in middleware or override the bundle’s `BreadcrumbBuilder` to integrate with Laravel’s `Route` service. Dynamic segments (e.g., `{id}`) would require custom logic to map to breadcrumb labels.
What Laravel versions and PHP versions are officially supported by this bundle?
This bundle is **not** officially supported in Laravel—it’s designed for Symfony 4.4+. However, it works with PHP 7.2+ (tested up to 8.2) and Laravel’s Service Container can host its services. For Laravel 8/9/10, ensure your PHP version matches the bundle’s requirements (e.g., PHP 8.1+ for Attributes).
How do I reset or clear the breadcrumb trail in Laravel (e.g., for dashboards with independent sections)?
Use the bundle’s `ResetBreadcrumbTrail` attribute on controller methods or middleware. In Laravel, trigger this via a middleware that clears the service’s trail before rendering. For dynamic resets (e.g., AJAX), dispatch a custom event or use Laravel’s `session()->forget('breadcrumb_trail')` if storing data there.
Are there performance concerns with using this bundle in Laravel, like reflection overhead?
Yes, the bundle uses reflection to parse Attributes/annotations, which adds runtime overhead. Mitigate this by caching the parsed metadata (e.g., store results in Laravel’s cache driver). Avoid recompiling Twig templates on every request—extract breadcrumb data in PHP and render statically in Blade if possible.
What are the security risks of using Twig for breadcrumbs in a Laravel app?
Twig introduces XSS risks if rendering unescaped user input (e.g., breadcrumb labels from databases). The bundle addresses this via Twig’s auto-escaping, but Laravel’s Blade uses different escaping rules. Ensure you sanitize dynamic labels before passing them to Twig or use Blade’s `{{ str_replace(e('...'), '...') }}` for consistency.
Can I test this bundle in a Laravel project without full integration?
Test the bundle’s core logic (e.g., Attribute parsing, service binding) in isolation using Laravel’s `Mockery` or PHPUnit. For Twig integration, mock the Twig environment or use a lightweight templating library like `php-twig` in a test container. Validate edge cases like nested routes or middleware sequencing separately.
What alternatives exist for Laravel breadcrumbs that don’t require Symfony dependencies?
Consider native Laravel packages like `spatie/laravel-breadcrumbs` (Blade-focused, no Twig/Symfony), `way/generators` (for route-based breadcrumbs), or `orchid/software` (for admin panels). These avoid Symfony’s ecosystem entirely and integrate seamlessly with Laravel’s routing and Blade. Evaluate based on your need for Attributes vs. simpler YAML/array configs.
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware