PHPackages                             chamber-orchestra/menu-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. [Templating &amp; Views](/categories/templating)
4. /
5. chamber-orchestra/menu-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

chamber-orchestra/menu-bundle
=============================

Symfony 8 navigation menu bundle with fluent tree builder, route-based active-item matching, role-based access control, runtime extensions for dynamic badges, PSR-6 tag-aware caching, and Twig rendering

v8.0.6(2mo ago)0305↓16.7%1MITPHPPHP ^8.5CI passing

Since Feb 19Pushed 2mo agoCompare

[ Source](https://github.com/chamber-orchestra/menu-bundle)[ Packagist](https://packagist.org/packages/chamber-orchestra/menu-bundle)[ Docs](https://github.com/chamber-orchestra/menu-bundle)[ RSS](/packages/chamber-orchestra-menu-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (27)Versions (9)Used By (1)

ChamberOrchestra MenuBundle
===========================

[](#chamberorchestra-menubundle)

[![PHP Composer](https://github.com/chamber-orchestra/menu-bundle/actions/workflows/php.yml/badge.svg)](https://github.com/chamber-orchestra/menu-bundle/actions/workflows/php.yml)[![PHPStan](https://camo.githubusercontent.com/745eb989b9e4903dc598fe2cc63ed4226198be55b7c729001cbd1ece7676fef6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e2e737667)](https://phpstan.org/)[![PHP-CS-Fixer](https://camo.githubusercontent.com/6ea88fbe545f6f06950dd97b31be7621fcb0a0056644de2ea36e44b7de33adc4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d5045522d2d435325323025324625323053796d666f6e792d626c75652e737667)](https://cs.symfony.com/)[![Latest Stable Version](https://camo.githubusercontent.com/2b91de6ae44e901a855675031c6e0d473ec7e8bea5a2b49fe8bd5d926a519377/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368616d6265722d6f72636865737472612f6d656e752d62756e646c652e737667)](https://packagist.org/packages/chamber-orchestra/menu-bundle)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP 8.5+](https://camo.githubusercontent.com/2371eeb1a98f81a6894947d4d7b429326ee7f4dbeb3d8940776b4ae7b8442725/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352532422d3737374242342e737667)](https://www.php.net/)[![Symfony 8.0](https://camo.githubusercontent.com/daaa476b3cc456701380f7d0fbdc3bbe9983e89d3267f99870daa88aa719e181/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d382e302d3030303030302e737667)](https://symfony.com/)

A **Symfony 8** bundle for building navigation menus, sidebars, and breadcrumbs — fluent tree builder, route-based active-item matching, role-based access control, runtime extensions for dynamic badges, PSR-6 tag-aware caching, and Twig rendering.

---

Features
--------

[](#features)

- **Fluent builder API** — `add()`, `children()`, `end()` for deeply-nested trees
- **Route-based matching** — `RouteVoter` marks the current item and its ancestors active; route values are treated as regex patterns
- **Custom voters** — implement `VoterInterface` to add custom matching logic alongside the built-in `RouteVoter`
- **Role-based access** — `Accessor` gates items by Symfony security roles; results are memoized per request
- **PSR-6 caching** — `AbstractCachedNavigation` caches the item tree for 24 h with tag-based invalidation
- **Runtime extensions** — `RuntimeExtensionInterface` runs post-cache on every request for fresh dynamic data without rebuilding the tree
- **Badge support** — `BadgeExtension` resolves `int` and `\Closure` badges at runtime; implement `RuntimeExtensionInterface` for service-injected dynamic badges
- **Counters** — `CounterExtension` resolves multiple named counters (`int` or `\Closure`) at runtime
- **Icons** — `IconExtension` moves the `icon` option into `extras['icon']` at build time
- **Dividers** — `DividerExtension` marks items as dividers via `extras['divider']` at build time
- **Visibility** — `VisibilityExtension` resolves `visible` (bool or `\Closure`) at runtime into `extras['visible']`
- **Label translation** — `TranslationExtension` translates item labels via Symfony's `TranslatorInterface` (auto-disabled when no translator is available)
- **Breadcrumbs** — `menu_breadcrumbs()` Twig function returns the path from root to the current item
- **Raw tree access** — `menu_get()` Twig function returns the root `Item` without rendering
- **Twig integration** — `render_menu()` function with fully customisable templates and optional default template
- **Bundle configuration** — centralised config for default template, translation domain, and cache namespace
- **Extension system** — build-time `ExtensionInterface` for cached option enrichment, runtime `RuntimeExtensionInterface` for post-cache processing
- **DI autoconfiguration** — implement an interface, done; no manual service tags required

---

Requirements
------------

[](#requirements)

DependencyVersionPHP`^8.5`ext-ds`*`doctrine/collections`^2.0 || ^3.0`symfony/\*`^8.0`symfony/translation-contracts`^3.4`twig/twig`^3.0`---

Installation
------------

[](#installation)

```
composer require chamber-orchestra/menu-bundle
```

### Register the bundle

[](#register-the-bundle)

```
// config/bundles.php
return [
    // ...
    ChamberOrchestra\MenuBundle\ChamberOrchestraMenuBundle::class => ['all' => true],
];
```

---

Configuration
-------------

[](#configuration)

```
# config/packages/chamber_orchestra_menu.yaml
chamber_orchestra_menu:
    default_template: ~              # ?string — fallback template for render_menu()
    translation:
        domain: 'messages'           # string — default translation domain for labels
    cache:
        namespace: '$NAVIGATION$'    # string — cache key namespace prefix
```

All values are optional with sensible defaults.

---

Quick Start
-----------

[](#quick-start)

### 1. Create a navigation class

[](#1-create-a-navigation-class)

```
