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

ActiveSymfony-bundle

zetta/menu-bundle
=================

Admin menu

v1.1.6(11y ago)91.4k2MITPHPPHP &gt;=5.4

Since Apr 2Pushed 10y ago3 watchersCompare

[ Source](https://github.com/zetta/MenuBundle)[ Packagist](https://packagist.org/packages/zetta/menu-bundle)[ Docs](http://github.com/zetta/menuBundle)[ RSS](/packages/zetta-menu-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (5)Versions (8)Used By (0)

ZettaMenuBundle
===============

[](#zettamenubundle)

One Menu To Rule Them All

This bundle is an extension of [KnpMenuBundle](https://github.com/KnpLabs/KnpMenuBundle) with which you can add a main menu for the system and this will be filtered depending on user role.

Features
--------

[](#features)

- The menus can be set from the configuration file `app/config/config.yml`
- The menu links are automatically filtered by the rules defined in the firewall
- [JMSSecurityExtraBundle](http://jmsyst.com/bundles/JMSSecurityExtraBundle/master/annotations#secure) annotations are supported for creating the filter
- Integration with existing menus on your bundle thanks to the [@SecureMenu](#simple-way) annotation

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

[](#requirements)

- PHP &gt;=5.4
- [KnpMenuBundle](https://github.com/KnpLabs/KnpMenuBundle)
- [KnpMenu](https://github.com/KnpLabs/KnpMenu)
- [JMSSecurityExtraBundle](https://github.com/schmittjoh/JMSSecurityExtraBundle)

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

[](#installation)

In order to install the bundle you need to add the dependency in `composer.json` file.

```
    //composer.json
    "require": {
        "zetta/menu-bundle" : "1.1.*"
    }
```

Then you must register the bundle in the kernel of the application.

```
// app/AppKernel.php
    $bundles = array(
        ....
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Zetta\MenuBundle\ZettaMenuBundle()
```

**It is important that the ZettaMenuBundle statement is after KnpMenuBundle**

Usage
-----

[](#usage)

There are two ways to filter our menus.

### Simple way

[](#simple-way)

If you use the [simple method](https://github.com/KnpLabs/KnpMenuBundle/blob/master/Resources/doc/index.md#method-a-the-easy-way-yay) for creating menus

```
// src/Acme/DemoBundle/Menu/Builder.php
namespace Acme\DemoBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;

class Builder extends ContainerAware
{
    public function mainMenu(FactoryInterface $factory, array $options)
    {
        $menu = $factory->createItem('root');

        $menu->addChild('Home', array('route' => 'homepage'));
        $menu->addChild('About Me', array(
            'route' => 'page_show',
            'routeParameters' => array('id' => 42)
        ));
        // ... add more children

        return $menu;
    }
}
```

Simply add the annotation `Zetta\MenuBundle\Annotation\SecureMenu` to the method to filter the items.

```
// src/Acme/DemoBundle/Menu/Builder.php
namespace Acme\DemoBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
use Zetta\MenuBundle\Annotation\SecureMenu;

class Builder extends ContainerAware
{
    /**
     * @SecureMenu
     */
    public function mainMenu(FactoryInterface $factory, array $options)
    {
        $menu = $factory->createItem('root');

        $menu->addChild('Home', array('route' => 'homepage'));
        $menu->addChild('About Me', array(
            'route' => 'page_show',
            'routeParameters' => array('id' => 42)
        ));
        // ... add more children

        return $menu;
    }
}
```

### Configuration Method `config.yml`

[](#configuration-method-configyml)

We define a menu in the configuration file

```
#app/config/config.yml
zetta_menu:
    menus:
        admin:
            childrenAttributes:
                class: 'nav'
            children:
                dashboard:
                    label: 'Dashboard'
                    route: '_welcome'
                users:
                    label: 'Users'
                    uri: '/user/'
                    extras:
                        safe_label: true
                    attributes:
                        id: 'user'
                    linkAttributes:
                        class: 'link'
                    children:
                        new:
                            label: 'New User'
                            uri: '/user/new'
                        archive:
                            label: 'User archive'
                            uri: '/user/archive'
                catalogs:
                    label: 'Catalogs'
                    route: 'catalogs'
                    children:
                        status:
                            label: 'Status'
                            uri: '/status/list'
                statistics:
                    label: 'Stats'
                    uri: '/admin/stats'

        sidebar:  #another one ...
            children:
                sidebar1:
                    label: "Sidebar 1"
```

Support KNP Menu Option

- attributes
- linkAttributes
- childrenAttributes
- labelAttributes
- extras
- displayChildren

Using the knp twig helper we can print it

```
    {{ knp_menu_render('admin') }}
```

By defailt if no deny rules exists in firewall or annotations the full menu will be printed

- Dashboard
- Users
    - New User
    - User Archive
- Catalogs
    - Status
- Stats

In order to affect the menu render we start to define rules in our firewall

```
#app/config/security.yml
security:

    role_hierarchy:
        ROLE_MANAGER:       ROLE_USER
        ROLE_ADMIN:         ROLE_MANAGER
    ...
    access_control:
        - { path: ^/admin/, role: ROLE_ADMIN }
        - { path: ^/user/new, role: ROLE_MANAGER }
        - { path: ^/$, role: ROLE_USER }
```

The system administrator can then see the full menu, however if a user authenticated with ROLE\_USER can only view:

- Dashboard
- Usuarios
    - Usuarios históricos
- Catálogos
    - Status

#### Annotations

[](#annotations)

Assuming we have catalogs route defined in `routing.yml`

```
#app/config/routing.yml
catalogs:
    pattern: /catalogs/
    defaults: {_controller: ExampleBundle:Catalogs:index}
```

We add the annotation in the controller's method

```
// src/Acme/ExampleBundle/Controller/CatalogsController.php
use JMS\SecurityExtraBundle\Annotation\Secure;

class CatalogsController{

    /**
     * @Secure(roles="ROLE_MANAGER")
     */
    public function indexAction()
    {
        // ... blah
    }

}
```

The same user with ROLE\_USER will see:

- Dashboard
- Usuarios
    - Usuarios históricos

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~101 days

Recently: every ~138 days

Total

7

Last Release

4185d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.2

v1.1.1PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/5653b5238327acd8b3009d880dd08be5929ec0ad3403cf14ff95072061140e55?d=identicon)[zetta](/maintainers/zetta)

---

Top Contributors

[![zetta](https://avatars.githubusercontent.com/u/204105?v=4)](https://github.com/zetta "zetta (42 commits)")[![angonyfox](https://avatars.githubusercontent.com/u/1295513?v=4)](https://github.com/angonyfox "angonyfox (7 commits)")

---

Tags

Menu management

### Embed Badge

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

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

Contao Open Source CMS

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

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128738.1k](/packages/auth0-symfony)

PHPackages © 2026

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