- How do I install szymat/breadcrumb-bundle with Composer?
- Run composer require szymat/breadcrumb-bundle in your Symfony project. If you are not using Symfony Flex, enable the bundle in your kernel or bundle configuration. Then add your breadcrumb definitions and render them from your templates. Check the repository README for the exact version constraints and registration steps.
- Does szymat/breadcrumb-bundle work with Laravel?
- No, szymat/breadcrumb-bundle is a Symfony bundle, not a Laravel package. It integrates with Symfony routing and request context rather than Laravel's service container and facades. Laravel applications should use a Laravel-specific breadcrumb package or a custom implementation.
- How do I define a breadcrumb trail declaratively?
- Define trails in configuration or a dedicated definition layer instead of hard-coding links in templates. The bundle is designed around declarative breadcrumb definitions and per-page trails. Keep labels and route references in one place so navigation logic is not duplicated across views. Consult the package docs for the exact definition format.
- How do I render breadcrumbs in a Twig template?
- Use the bundle's rendering helper from your Twig template after the trail has been generated. The package provides simple rendering helpers for outputting the navigation markup. Keep presentation in the template and trail definitions in configuration. Verify the helper name and escaping behavior in the repository documentation.
- Can breadcrumbs be generated automatically from the current route?
- Yes, the bundle is route- and request-aware and can build a trail that reflects the current page. You can define per-page or per-route trails so the breadcrumb output matches the site hierarchy. Dynamic route parameters can be reflected through request context, depending on how you define the trail. This avoids duplicating navigation logic in every controller or view.
- How do I override a breadcrumb for one specific page?
- The bundle is described as easy to extend or override for custom trails. Define a page-specific trail or override the relevant crumb definition for that route. Keep the override close to the route definition so it is easy to find. Check the documented extension points before modifying vendor code.
- Can I use dynamic route parameters in breadcrumb labels?
- Because trail generation is request-aware, breadcrumb labels and links can reflect data from the current request. The exact syntax for injecting route parameters depends on the bundle's definition and rendering helpers. Use the documented request context API rather than manually parsing the URL. Test the trail with real parameter values to confirm escaping and links.
- Is szymat/breadcrumb-bundle safe to use in production?
- It is a lightweight package with minimal dependencies, which keeps the integration surface small. Before production use, check the repository's recent commits, issue activity, and supported Symfony versions. Always escape rendered breadcrumb labels and validate any route parameters used in links. Breadcrumbs are navigation, not an authorization mechanism, so protect pages with normal access control.
- How do I test breadcrumb trails in a Symfony application?
- Write functional tests that request a route and assert the rendered breadcrumb markup or trail data. For unit tests, instantiate the trail-building service with a mocked request or router context. Cover per-page definitions, dynamic parameters, and missing-route cases. Use Symfony's test client and keep assertions focused on labels, order, and URLs.
- What are alternatives to szymat/breadcrumb-bundle?
- Alternatives include other Symfony breadcrumb bundles, menu-building bundles such as KnpMenuBundle, or a small custom service that builds an array of crumbs. For Laravel, use a Laravel-specific breadcrumb package instead. Choose based on maintenance activity, Symfony version support, and whether you need automatic route-based trails or fully manual definitions.