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

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

lch/menu-bundle
===============

Gives a simple Wordpress like menu management system for Symfony

1.2.2(5y ago)06901[2 issues](https://github.com/compagnie-hyperactive/MenuBundle/issues)1MITJavaScriptPHP ^7.0CI failing

Since May 24Pushed 5y ago4 watchersCompare

[ Source](https://github.com/compagnie-hyperactive/MenuBundle)[ Packagist](https://packagist.org/packages/lch/menu-bundle)[ Docs](https://github.com/compagnie-hyperactive/MenuBundle)[ RSS](/packages/lch-menu-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (7)Versions (18)Used By (1)

MenuBundle
==========

[](#menubundle)

This provides a simple handling for menu items, based on Wordpress idea. You define **menu locations**, and then you retrieve menu items assigned on this location using a Twig extension.

For item editing part in BO, the bundle provides a `MenuType` and CSS/JS part for drag-n drop feature.

This bundle is translatable, using [lch/translatable-bundle](https://github.com/compagnie-hyperactive/TranslateBundle).

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

[](#installation)

`composer require lch/menu-bundle "^1.1.8"`

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

[](#configuration)

After installing, create a `lch_menu.yaml` in `config/packages`. You can now defines your **menus locations**, for example :

```
lch_menu:
  locations:
    header:
      title: Header
    main:
      title: Main navigation
    footer_buttons:
      title: Footer - buttons
    footer_left:
      title: Footer - left
# ...
```

Admin part
----------

[](#admin-part)

This is entirely up to you, but you have to use `Lch\MenuBundle\Entity\Menu` class on you CRUD. CRUD example below :

```
namespace App\Controller\Admin;

use App\Form\Type\Extension\MenuTypeExtension;
use App\Repository\MenuRepository;
use Lch\MenuBundle\Entity\Menu;
use Lch\MenuBundle\Form\MenuType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

/**
 * @Route("/admin/menu")
 * @IsGranted("ROLE_ADMIN")
 */
class MenuController extends AbstractController
{
    /**
     * @Route(
     *     "/{page}",
     *     name="admin.menu.list",
     *     requirements={"page"="[1-9]\d*"},
     *     defaults={"page"=1}
     * )
     *
     * @param int $page
     *
     * @return Response
     */
    public function list(int $page): Response
    {
        $nbItemsPerPage = 20;

        /** @var MenuRepository $r */
        $r = $this->getDoctrine()->getRepository(Menu::class);
        $menus = $r->getPaginatedList($page, $nbItemsPerPage, [], [], true);

        return $this->render('admin/menu/list.html.twig', [
            'menus' => $menus,
            'pagination' => [
                'page' => $page,
                'nbPages' => ceil($menus->count() / $nbItemsPerPage)
            ]
        ]);
    }

    /**
     * @Route("/create", name="admin.menu.create")
     *
     * @param Request $request
     *
     * @return Response
     */
    public function create(Request $request): Response
    {
        return $this->edit(new Menu(), $request);
    }

    /**
     * @Route("/edit/{id}", name="admin.menu.edit")
     *
     * @param Menu $menu
     * @param Request $request
     *
     * @return Response
     */
    public function edit(Menu $menu, Request $request): Response
    {
        // Use the MenuType from bundle
        $form = $this->createForm(MenuType::class, $menu);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($menu);
            $em->flush();
            if ($form->get('save')->get('save')->isClicked()) {
                return $this->redirectToRoute('admin.menu.list');
            }
            return $this->redirectToRoute('admin.menu.edit', ['id' => $menu->getId()]);
        }

        return $this->render('admin/menu/edit.html.twig', [
            'menu' => $menu,
            'form' => $form->createView()
        ]);
    }
    /**
     * @Route("/delete/{id}", name="admin.menu.delete")
     * @Method({"GET", "DELETE"})
     *
     * @param Menu $menu
     * @param Request $request
     * @return Response
     */
    public function delete(Menu $menu, Request $request): Response
    {
        $form = $this->createFormBuilder()
            ->setMethod('DELETE')
            ->add('delete', SubmitType::class, [
                'attr' => [
                    'class' => 'btn btn-danger'
                ]
            ])
            ->getForm();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->remove($menu);
            $em->flush();

            return $this->redirectToRoute('admin.menu.list');
        }

        return $this->render('admin/menu/delete.html.twig', [
            'menu' => $menu,
            'form' => $form->createView()
        ]);
    }
}
```

Drag'n drop part
----------------

[](#dragn-drop-part)

You must include CSS and JS components in your Webpack admin entrypoint :

```
// ...
require('../../vendor/lch/menu-bundle/Resources/public/css/lch_menu.css');
require('../../vendor/lch/menu-bundle/Resources/public/js/lch_menu');
//...
```

Screenshots
-----------

[](#screenshots)

Using code above, this can provide following presentation : [![Menu listing](https://camo.githubusercontent.com/f8ff92795531b86ec5946f9baeceb17db5587c88821cf6553bde761dec41109c/68747470733a2f2f636f6d7061676e69652d68797065726163746976652e6769746875622e696f2f4d656e7542756e646c652f696d616765732f6c697374696e672e706e67)](https://camo.githubusercontent.com/f8ff92795531b86ec5946f9baeceb17db5587c88821cf6553bde761dec41109c/68747470733a2f2f636f6d7061676e69652d68797065726163746976652e6769746875622e696f2f4d656e7542756e646c652f696d616765732f6c697374696e672e706e67)

[![Menu editing](https://camo.githubusercontent.com/5c580977d0c0495b92ee18cce619dc68f74382663dd9a5369a033b447babeb0b/68747470733a2f2f636f6d7061676e69652d68797065726163746976652e6769746875622e696f2f4d656e7542756e646c652f696d616765732f65646974696e672e706e67)](https://camo.githubusercontent.com/5c580977d0c0495b92ee18cce619dc68f74382663dd9a5369a033b447babeb0b/68747470733a2f2f636f6d7061676e69652d68797065726163746976652e6769746875622e696f2f4d656e7542756e646c652f696d616765732f65646974696e672e706e67)

Menu item composition
---------------------

[](#menu-item-composition)

Each menu item is composed with a title, a link and a field called **technical tags**. This last one is to be used for carrying any context you would latter need on presentation. This bundle provides only normalization stage on menu items, it up to the template to create presentation that suits to your needs.

*note : in the screenshot above, technical tags carry an SVG icon name.*

Menu retrieval
--------------

[](#menu-retrieval)

To get menus data, you must use `get_menu_items` Twig extension :

```
{% for menuItem in get_menu_items('header', locale) %}

            {% if(menuItem.tags|length > 0) %}

            {% endif %}
            {{ menuItem.name }}

{% endfor %}
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~85 days

Recently: every ~67 days

Total

15

Last Release

2114d ago

Major Versions

0.5 → 1.02017-07-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9247311?v=4)[lch](/maintainers/lch)[@lch](https://github.com/lch)

---

Top Contributors

[![devgiants](https://avatars.githubusercontent.com/u/8057208?v=4)](https://github.com/devgiants "devgiants (38 commits)")[![Adrien-H](https://avatars.githubusercontent.com/u/23212260?v=4)](https://github.com/Adrien-H "Adrien-H (7 commits)")[![azribilel](https://avatars.githubusercontent.com/u/15249313?v=4)](https://github.com/azribilel "azribilel (1 commits)")

---

Tags

symfonymenumanagement

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[jbtronics/settings-bundle

A symfony bundle to easily create typesafe, user-configurable settings for symfony applications

9558.8k3](/packages/jbtronics-settings-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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