PHPackages                             kalamu/menu-service-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. kalamu/menu-service-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kalamu/menu-service-bundle
==========================

Service to provide knp menu by configuration

v2.0.0(8y ago)11.8k1MITPHP

Since Jul 7Pushed 8y ago2 watchersCompare

[ Source](https://github.com/kalamu/menu-service-bundle)[ Packagist](https://packagist.org/packages/kalamu/menu-service-bundle)[ RSS](/packages/kalamu-menu-service-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (1)

MenuServiceBundle
=================

[](#menuservicebundle)

This bundle provide a menu service for knp/menu-bundle that is configurable by config file.

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

[](#installation)

```
composer require kalamu/menu-service-bundle:^2.0
```

Puis ajouter dans `AppKernel.php`

```
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Kalamu\MenuServiceBundle\KalamuMenuServiceBundle(),
        );
    }
```

How to build a menu
-------------------

[](#how-to-build-a-menu)

To build a menu, you just have to add the items in your `app/config/config.yml` file :

```
kalamu_menu_service:
    menu_name:
        items:
            - {label: "Home", route: home_route, icon: '' }
            - {label: "Item 1", route: item1_route, icon: '' }
            ...
```

Then, to add the menu in the template :

```

    {{knp_menu_render('menu_name', {'allow_safe_labels': true})}}

```

Security
--------

[](#security)

### Restrict access by roles

[](#restrict-access-by-roles)

The `roles` option allow to control if an item is available to an user depending on his authorizations. This option take an array of roles. The user must be authorized for each of theses roles to see the item.

Example:

```
kalamu_menu_service:
    menu_name:
        items:
            - {label: "Home", route: home_route, icon: '', roles: ['ROLE_USER', 'ROLE_OPEN_DOOR'] }
```

To access the `home` item, the user must have both roles `ROLE_USER` and `ROLE_OPEN_DOOR`.

### Restrict access by expression

[](#restrict-access-by-expression)

The 'allow\_if' option provide a more customizable way to handle the restrictions. The option take an expression as argument. For more information about the syntax, see the documentation about [How to use Expressions in Security](http://symfony.com/doc/current/expressions.html#security-complex-access-controls-with-expressions).

Example:

```
kalamu_menu_service:
    menu_name:
        items:
            - {label: "Home", route: home_route, icon: '', allow_if: "has_role('ROLE_USER') or has_role('ROLE_OPEN_DOOR')" }
```

To access the *Home* item, the user must have either the role `ROLE_USER` or the role `ROLE_OPEN_DOOR`.

The option `roles` can be used in combination with the `allow_if` options. In such case, both constraints must be satisfied to grant access.

### Restrict access by hierarchy

[](#restrict-access-by-hierarchy)

On a menu with hierarchical items, most of the time the parent item has no sens without his children. So it must be removed if all children are not accessible to the current user.

If there is only a few underlying roles, this could be handled with the `allow_if`option. But if the number of constraints grow, the task become uselessly cumbersome.

The `hide_if_no_child` option solve this problem. If set to true, the item is available only if the user has access to at least one child.

Example:

```
kalamu_menu_service:
    menu_name:
        items:
            -
                label: "User management"
                route: ''
                hide_if_no_child: true
                items:
                    - {label: "Users", route: user_list, roles: ['ROLE_MANAGE_USER'] }
                    - {label: "Groups", route: group_list, allow_if: '(user and user.isSuperAdmin())) or user.isGoodManager()' }
```

Customisation
-------------

[](#customisation)

If you want to change interactivly you menu, you can use the events `kalamu.menu_service.configure.{menu_name}`. For more informations on knp/menu-bundle :

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~140 days

Recently: every ~108 days

Total

6

Last Release

2934d ago

Major Versions

v1.1.1 → v2.0.02018-06-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b12ed423a03cfb7eb41e4a0b5c1182ab30271cfc4f3f3e5962bb73873aca37f?d=identicon)[nykopol](/maintainers/nykopol)

---

Top Contributors

[![nykopol](https://avatars.githubusercontent.com/u/2706685?v=4)](https://github.com/nykopol "nykopol (10 commits)")

---

Tags

knpsymfonysymfony-bundle

### Embed Badge

![Health badge](/badges/kalamu-menu-service-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kalamu-menu-service-bundle/health.svg)](https://phpackages.com/packages/kalamu-menu-service-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.

3691.3k16](/packages/netgen-layouts-core)

PHPackages © 2026

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