Download the PHP package mikamatto/breadcrumbs-bundle without Composer
On this page you can find all versions of the php package mikamatto/breadcrumbs-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mikamatto/breadcrumbs-bundle
More information about mikamatto/breadcrumbs-bundle
Files in mikamatto/breadcrumbs-bundle
Package breadcrumbs-bundle
Short Description A Symfony bundle for managing breadcrumbs.
License MIT
Informations about the package breadcrumbs-bundle
BreadcrumbsBundle
Mikamatto\BreadcrumbsBundle
is a Symfony bundle that provides easy-to-configure breadcrumbs functionality using a YAML file. It supports a simple, chain-based breadcrumb structure and includes caching for optimized performance.
Installation
Use Composer to install the bundle:
Configuration
By default, the breadcrumbs configuration file should be located at config/packages/breadcrumbs.yaml
. The structure inside this file should start with a breadcrumbs_bundle root key, as follows:
Each route is defined by:
- label: The breadcrumb label which will be rendered in the breadcrumb.
- chain: Optional. Defines the chain of preceding routes (as an array of route names) which will be rendered recursively.
Custom File Path
If you prefer a custom file name, you can specify it in your configuration file as follows:
Note: If you use a custom filename but do not specify it in the configuration, the bundle will work; however, caching will default to config/packages/breadcrumbs.yaml, which may lead to outdated breadcrumbs being displayed. Defining the path explicitly ensures cache invalidation occurs correctly.
This approach maintains flexibility while ensuring caching behaves as expected for any filename or location.
Usage
1. Twig Function
Use the Twig function getBreadcrumbs()
to retrieve the breadcrumb chain for the current route.
This will output something like:
Note: To keep things lighter, the common root ‘Home’ can be hardcoded in Twig instead of being defined in each route chain.
2. Service: BreadcrumbsProcessor
You can also access the underlying service: the bundle exposes a BreadcrumbsProcessor
service, which generates breadcrumb arrays for a given route.
Inject the service (Mikamatto\BreadcrumbsBundle\Service\BreadcrumbsProcessor) and call generateBreadcrumbs():
Caching
The bundle caches the breadcrumbs YAML file for performance. When the YAML file changes, the cache automatically invalidates and updates. A dedicated cache pool is used, defined in your bundle’s service configuration.
Example Output
The output of getBreadcrumbs()
in Twig (or generateBreadcrumbs()
as a service) will look like this:
Summary
- Breadcrumbs YAML configuration defines route labels and chains.
- Service
BreadcrumbsProcessor
generates breadcrumbs for specified routes. - Twig function
getBreadcrumbs()
automatically provides breadcrumbs for the current route. - Caching is automatically managed on YAML changes for optimized performance.
This structure allows you to integrate breadcrumbs easily with flexible customization options.
All versions of breadcrumbs-bundle with dependencies
symfony/framework-bundle Version ^5.0|^6.0|^7.0
symfony/yaml Version ^5.0|^6.0|^7.0
symfony/routing Version ^5.0|^6.0|^7.0