PHPackages                             diabl0/config-knp-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. diabl0/config-knp-menu-bundle

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

diabl0/config-knp-menu-bundle
=============================

Configure your knp menus with yaml files accross your project bundles

0.9.4(6y ago)08382MITPHP

Since Feb 6Pushed 6y agoCompare

[ Source](https://github.com/diabl0/ConfigKnpMenuBundle)[ Packagist](https://packagist.org/packages/diabl0/config-knp-menu-bundle)[ Docs](https://github.com/diabl0/ConfigKnpMenuBundle)[ RSS](/packages/diabl0-config-knp-menu-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

ConfigKnpMenuBundle
===================

[](#configknpmenubundle)

[![Build Status](https://camo.githubusercontent.com/b0a33cca13612978da6bc2a85919f6c3054d4ee09238c322798d93b0b384448f/68747470733a2f2f7472617669732d63692e6f72672f6a626f757a656b72692f436f6e6669674b6e704d656e7542756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jbouzekri/ConfigKnpMenuBundle)[![SensioLabsInsight](https://camo.githubusercontent.com/8608fa9e16ea7ce51a38652780c7f4c852de62e9245d41b8dbe2e6291f3fa13d/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f30626133653265362d346239312d343838362d616138642d3436323065623234333834352f6d696e692e706e67)](https://insight.sensiolabs.com/projects/0ba3e2e6-4b91-4886-aa8d-4620eb243845)

Introduction
------------

[](#introduction)

This bundle provides a way to configure your knp menus via yaml configuration file.

For more information on knp menu, read :

- The [Knp Menu Documentation](https://github.com/KnpLabs/KnpMenu/blob/master/README.markdown)
- The [Knp Menu Bundle Documentation](https://github.com/KnpLabs/KnpMenuBundle/blob/master/README.md)

This bundle was inspired by the [OroNavigationBundle](https://github.com/orocrm/platform/tree/master/src/Oro/Bundle/NavigationBundle) and [jbouzekri/ConfigKnpMenuBundle](https://github.com/jbouzekri/ConfigKnpMenuBundle)

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

[](#installation)

You can use composer for installation.

```
composer require diabl0/config-knp-menu-bundle
```

Documentation
-------------

[](#documentation)

In order to use this bundle, you must define your menu configuration in a **navigation.yaml** file in your configs (usually /config/packages/navigation.yaml). If you are using Flex, this config is created for you.

format :

```
# Default configuration for extension with alias: "config_knp_menu"
config_knp_menu:
    menu:
        name:
            tree:

                # Prototype
                name:
                    route:                ~
                    routeParameters:      []
                    uri:                  ~
                    label:                ~
                    display:              true
                    displayChildren:      true
                    order:                ~
                    attributes:           []
                    linkAttributes:       []
                    childrenAttributes:   []
                    labelAttributes:      []
                    roles:                []
                    extras:               []
                    children:

                        # Prototype
                        name:
                            route:                ~
                            routeParameters:      []
                            uri:                  ~
                            label:                ~
                            display:              true
                            displayChildren:      true
                            order:                ~
                            attributes:           []
                            linkAttributes:       []
                            childrenAttributes:   []
                            labelAttributes:      []
                            roles:                []
                            extras:               []
                            children:
```

Example :

```
config_knp_menu:
  menu:
    # main menu
    my_mega_menu:
      tree:
        home:
          label: Home
          route: index
        one:
          label: One
          attributes:
            icon: fa-award
          children:
            oo:
              label: Eleven
              route: app_one
              extras:
                routes:
                  - app_one_list
                  - app_one_edit
                  - app_one_new
            ot:
              label: Twelfe
              uri: "#12"
```

It will configure a provider for knp menu factory. You can then use your my\_mega\_menu in twig as a classic knp menu :

```
{{ knp_menu_render('my_mega_menu') }}
```

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

[](#configuration)

This is the available configuration definition for an item.

```
        menu_key:
            uri: "An uri. Use it if you do not define route parameter"
            route: "A sf2 route without @"
            routeParameters: "an array of parameters to pass to the route"
            label: "My first label"
            order: An integer to sort the item in his level.
            attributes: An array of attributes passed to the knp item.
                        You can use it to pass additional data to twig template like icons, styles etc.
            linkAttributes: An array of attributes passed to the a tag
            childrenAttributes: An array of attributes passed to the children block
            labelAttributes: An array of attributes passed to the label tag
            display: boolean to hide the item
            displayChildren: boolean to hide the children
            roles: array of item (string roles) passed to isGranted securityContext method to check if user has rights in menu items
            extras: An array of extra parameters (for example icon img, additional content etc.)
            children: # An array of subitems
                second_level_item:
                    label: My second level
```

This configuration matches the methods available in the Knp Menu Item class

Menu security
-------------

[](#menu-security)

Security context is injected in menu item provider.

For root menu item, display or hide it in your twig template. For children items, if you didn't add the roles key, they will be displayed. Else it will passed the array of key to the isGranted method and check if you have rights on the the item.

Breadcrumbs
-----------

[](#breadcrumbs)

Simple example:

```

                            {% for breadcrumb_item in knp_menu_get_breadcrumbs_array(knp_menu_get_current_item('main')) %}

                                    {% if  breadcrumb_item.uri is not empty %}

                                    {% endif %}
                                    {{ breadcrumb_item.label }}
                                    {% if  breadcrumb_item.uri is not empty %}

                                    {% endif %}

                            {% endfor %}

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.2% of commits — single point of failure

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 ~72 days

Total

5

Last Release

2363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/857650ae606779a8a46e7f69f9eb6afa92d2d5d386766c32ce0a7e978557502b?d=identicon)[diabl0](/maintainers/diabl0)

---

Top Contributors

[![jbouzekri](https://avatars.githubusercontent.com/u/880996?v=4)](https://github.com/jbouzekri "jbouzekri (54 commits)")[![diabl0](https://avatars.githubusercontent.com/u/2463020?v=4)](https://github.com/diabl0 "diabl0 (11 commits)")[![munkie](https://avatars.githubusercontent.com/u/102297?v=4)](https://github.com/munkie "munkie (11 commits)")[![kampfq](https://avatars.githubusercontent.com/u/7052906?v=4)](https://github.com/kampfq "kampfq (1 commits)")[![netfarma](https://avatars.githubusercontent.com/u/1618812?v=4)](https://github.com/netfarma "netfarma (1 commits)")

---

Tags

symfonyknpuimenunavigationuser-interface

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/diabl0-config-knp-menu-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/diabl0-config-knp-menu-bundle/health.svg)](https://phpackages.com/packages/diabl0-config-knp-menu-bundle)
```

###  Alternatives

[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[caffeinated/menus

Laravel Menus

134159.5k5](/packages/caffeinated-menus)[gourmet/knp-menu

KnpMenu for CakePHP 3

1450.7k3](/packages/gourmet-knp-menu)[swiegmann/kirby-menu

This Kirby CMS-Plugin lets you build and render structured menues with a variety of features.

141.4k](/packages/swiegmann-kirby-menu)

PHPackages © 2026

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