PHPackages                             huluti/breadcrumbs-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. huluti/breadcrumbs-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

huluti/breadcrumbs-bundle
=========================

Breadcrumbs bundle for Symfony

1.7.0(2mo ago)013.0k↓15.8%1MITPHPPHP ^8.2CI passing

Since Jan 21Pushed 2mo agoCompare

[ Source](https://github.com/Huluti/BreadcrumbsBundle)[ Packagist](https://packagist.org/packages/huluti/breadcrumbs-bundle)[ Docs](https://github.com/Huluti/BreadcrumbsBundle)[ RSS](/packages/huluti-breadcrumbs-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (19)Versions (3)Used By (1)

*This is a fork of [mhujer/BreadcrumbsBundle](https://github.com/mhujer/BreadcrumbsBundle), maintained for newer Symfony versions. The original bundle itself is a fork of [sampart/BreadcrumbsBundle](https://github.com/sampart/BreadcrumbsBundle).*

[![Packagist Version](https://camo.githubusercontent.com/50529d095beadc212d9f8aa4f4924231aa9a0b03b02709d740590f0047e3684b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756c7574692f62726561646372756d62732d62756e646c65)](https://camo.githubusercontent.com/50529d095beadc212d9f8aa4f4924231aa9a0b03b02709d740590f0047e3684b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756c7574692f62726561646372756d62732d62756e646c65)

Goal
----

[](#goal)

This bundle provides an easy and flexible way to manage **breadcrumbs** in Symfony applications. It allows developers to dynamically build breadcrumbs for controllers and templates.

Requirements
============

[](#requirements)

- PHP 8.2 or higher
- Symfony 7.4 or higher

Installation
============

[](#installation)

1. Install this bundle using [Composer](https://getcomposer.org/):

    ```
    composer require huluti/breadcrumbs-bundle
    ```

If you're using Symfony Flex, the following steps will be done automatically.

2. Enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Huluti\BreadcrumbsBundle\HulutiBreadcrumbsBundle::class => ['all' => true],
];
```

3. Configure the bundle in `config/packages/huluti_breadcrumbs.yaml`:

    ```
    # config/packages/huluti_breadcrumbs.yaml
    huluti_breadcrumbs: ~
    ```

That's it for basic configuration. For more options check the [Configuration](#configuration) section.

Usage
=====

[](#usage)

In your application controller methods:

```
use Huluti\BreadcrumbsBundle\Model\Breadcrumbs;

public function yourAction(User $user, Breadcrumbs $breadcrumbs)
{
    // Simple example
    $breadcrumbs->addItem("Home", $this->get("router")->generate("index"));

    // Example without URL
    $breadcrumbs->addItem("Some text without link");

    // Example with parameter injected into translation "user.profile"
    $breadcrumbs->addItem($txt, $url, ["%user%" => $user->getName()]);
}
```

or with attributes and [PropertyAccess Component](https://symfony.com/doc/current/components/property_access.html)

```
use Huluti\BreadcrumbsBundle\Attribute\Breadcrumb;

#[Breadcrumb(text: 'firstBreadcrumb', route: 'app_main')]
class Controller extends AbstractController{

    #[Breadcrumb(text: 'nextBreadcrumb', route: 'app_main')]
    #[Breadcrumb(text: 'nextBreadcrumb', url: '/')]
    #[Breadcrumb(text: 'nextBreadcrumb  {user.name} in {category.name}', route: 'app_main', parameters: ['id' => '{user.id}', 'category' => '{category.name}'])]
    public function yourAction(User $user, Category $category)
    {
    }
}
```

Then, in your template:

```
{{ wo_render_breadcrumbs() }}
```

The last item in the breadcrumbs collection will automatically be rendered as plain text rather than a `...` tag.

The `addItem()` method adds an item to the *end* of the breadcrumbs collection. You can use the `prependItem()` method to add an item to the *beginning* of the breadcrumbs collection. This is handy when used in conjunction with hierarchical data (e.g. Doctrine Nested-Set). This example uses categories in a product catalog:

```
public function yourAction(Category $category)
{
    $breadcrumbs = $this->get("huluti_breadcrumbs");

    $node = $category;

    while ($node) {
        $breadcrumbs->prependItem($node->getName(), "");

        $node = $node->getParent();
    }
}
```

If you do not want to generate a URL manually, you can easily add breadcrumb items passing only the route name with any required parameters, using the `addRouteItem()`and `prependRouteItem()` methods:

```
public function yourAction()
{
    $breadcrumbs = $this->get("huluti_breadcrumbs");

    // Pass "_demo" route name without any parameters
    $breadcrumbs->addRouteItem("Demo", "_demo");

    // Pass "_demo_hello" route name with route parameters
    $breadcrumbs->addRouteItem("Hello Breadcrumbs", "_demo_hello", [
        'name' => 'Breadcrumbs',
    ]);

    // Add "homepage" route link at the start of the breadcrumbs
    $breadcrumbs->prependRouteItem("Home", "homepage");
}
```

Configuration
=============

[](#configuration)

The following *default* parameters can be overridden in your `config/packages/huluti_breadcrumbs.yaml`:

```
# config/packages/huluti_breadcrumbs.yaml
huluti_breadcrumbs:
    separator:          '/'
    separatorClass:     'separator'
    listId:             'wo-breadcrumbs'
    listClass:          'breadcrumb'
    itemClass:          ''
    linkRel:            ''
    locale:             ~ # defaults to null, so the default locale is used
    translation_domain: ~ # defaults to null, so the default domain is used
    viewTemplate:       '@HulutiBreadcrumbs/microdata.html.twig'
```

These can also be passed as parameters in the view when rendering the breadcrumbs - for example:

```
{{ wo_render_breadcrumbs({separator: '>', listId: 'breadcrumbs'}) }}
```

> **NOTE:** If you need more than one set of breadcrumbs on the same page you can use namespaces. By default, breadcrumbs use the `default` namespace, but you can add more. To add breadcrumbs to your custom namespace use `addNamespaceItem` / `prependNamespaceItem`or `addNamespaceRouteItem` / `prependNamespaceRouteItem` methods respectively, for example:

```
public function yourAction(User $user)
{
    $breadcrumbs = $this->get("huluti_breadcrumbs");

    // Simple example
    $breadcrumbs->prependNamespaceItem("subsection", "Home", $this->get("router")->generate("index"));

    // Example without URL
    $breadcrumbs->addNamespaceItem("subsection", "Some text without link");

    // Example with parameter injected into translation "user.profile"
    $breadcrumbs->addNamespaceItem("subsection", $txt, $url, ["%user%" => $user->getName()]);

    // Example with route name with required parameters
    $breadcrumbs->addNamespaceRouteItem("subsection", $user->getName(), "user_show", ["id" => $user->getId()]);
}
```

Then to render the `subsection` breadcrumbs in your templates, specify this namespace in the options:

```
{{ wo_render_breadcrumbs({namespace: "subsection"}) }}
```

Advanced Usage
==============

[](#advanced-usage)

You can add a whole array of objects at once

```
$breadcrumbs->addObjectArray(array $objects, $text, $url, $translationParameters);
```

```
objects:            array of objects
text:               name of object property or closure
url:                name of URL property or closure

```

Example:

```
$that = $this;
$breadcrumbs->addObjectArray($selectedPath, "name", function($object) use ($that) {
    return $that->generateUrl('_object_index', ['slug' => $object->getSlug()]);
});
```

You can also add a tree path

```
$breadcrumbs->addObjectTree($object, $text, $url = "", $parent = 'parent', array $translationParameters = [], $firstPosition = -1)
```

```
object:             object to start with
text:               name of object property or closure
url:                name of URL property or closure
parent:             name of parent property or closure
firstPosition:      position to start inserting items (-1 = determine automatically)

```

> **NOTE:** You can use `addNamespaceObjectArray` and `addNamespaceObjectTree` respectively for work with multiple breadcrumbs on the same page.

Overriding the template
=======================

[](#overriding-the-template)

There are two methods for doing this.

1. You can override the template used by copying the `Resources/views/microdata.html.twig` file out of the bundle and placing it into `/templates/bundles/HulutiBreadcrumbsBundle`, then customising as you see fit. Check the [Overriding bundle templates](https://symfony.com/doc/current/bundles/override.html#templates) documentation section for more information.
2. Use the `viewTemplate` configuration parameter:

    ```
    {{ wo_render_breadcrumbs({ viewTemplate: "@HulutiBreadcrumbs/yourBreadcrumbs.html.twig" }) }}
    ```

> **NOTE:** If you want to use the JSON-LD format, there's already an existing template at `@HulutiBreadcrumbs/json-ld.html.twig`. Just set this template as the value for `viewTemplate` either in your Twig function call (see Step 2 above) or in your bundle [configuration](#configuration).

Contributing
============

[](#contributing)

We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).

If you'd like to contribute code but aren't sure what, the [issues list](https://github.com/Huluti/breadcrumbsbundle/issues) is a good place to start. If you're a first-time code contributor, you may find Github's guide to [forking projects](https://guides.github.com/activities/forking/) helpful.

All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our [code of conduct](https://github.com/Huluti/open-source-code-of-conduct/blob/main/code_of_conduct.md).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance85

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Total

2

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0a1f1e33e08fa712c9bb1fd685235c63a712c370af3c1c74792180115a62893?d=identicon)[hugoposnic](/maintainers/hugoposnic)

---

Top Contributors

[![richsage](https://avatars.githubusercontent.com/u/231551?v=4)](https://github.com/richsage "richsage (60 commits)")[![mhujer](https://avatars.githubusercontent.com/u/353372?v=4)](https://github.com/mhujer "mhujer (59 commits)")[![Huluti](https://avatars.githubusercontent.com/u/5782198?v=4)](https://github.com/Huluti "Huluti (24 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (16 commits)")[![balazslevi](https://avatars.githubusercontent.com/u/12248065?v=4)](https://github.com/balazslevi "balazslevi (16 commits)")[![toooni](https://avatars.githubusercontent.com/u/241080?v=4)](https://github.com/toooni "toooni (5 commits)")[![andrewmy](https://avatars.githubusercontent.com/u/715595?v=4)](https://github.com/andrewmy "andrewmy (3 commits)")[![basdenooijer](https://avatars.githubusercontent.com/u/580644?v=4)](https://github.com/basdenooijer "basdenooijer (3 commits)")[![maxhelias](https://avatars.githubusercontent.com/u/12966574?v=4)](https://github.com/maxhelias "maxhelias (2 commits)")[![andreybolonin](https://avatars.githubusercontent.com/u/2576509?v=4)](https://github.com/andreybolonin "andreybolonin (2 commits)")[![COil](https://avatars.githubusercontent.com/u/177844?v=4)](https://github.com/COil "COil (2 commits)")[![dxops](https://avatars.githubusercontent.com/u/1804871?v=4)](https://github.com/dxops "dxops (2 commits)")[![micotodev](https://avatars.githubusercontent.com/u/1260246?v=4)](https://github.com/micotodev "micotodev (2 commits)")[![quentin-st](https://avatars.githubusercontent.com/u/1551971?v=4)](https://github.com/quentin-st "quentin-st (2 commits)")[![sampart](https://avatars.githubusercontent.com/u/1507328?v=4)](https://github.com/sampart "sampart (2 commits)")[![Simounet](https://avatars.githubusercontent.com/u/582666?v=4)](https://github.com/Simounet "Simounet (2 commits)")[![wickedOne](https://avatars.githubusercontent.com/u/343850?v=4)](https://github.com/wickedOne "wickedOne (1 commits)")[![modywzm](https://avatars.githubusercontent.com/u/1086434?v=4)](https://github.com/modywzm "modywzm (1 commits)")[![nexxome](https://avatars.githubusercontent.com/u/2526962?v=4)](https://github.com/nexxome "nexxome (1 commits)")[![Nickinthebox](https://avatars.githubusercontent.com/u/2796997?v=4)](https://github.com/Nickinthebox "Nickinthebox (1 commits)")

---

Tags

symfonysymfony-bundlesymfonybreadcrumbs

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/huluti-breadcrumbs-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/huluti-breadcrumbs-bundle/health.svg)](https://phpackages.com/packages/huluti-breadcrumbs-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[pentatrion/vite-bundle

Vite integration for your Symfony app

2725.3M13](/packages/pentatrion-vite-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
