PHPackages                             enimiste/knp-menu-laravel - 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. enimiste/knp-menu-laravel

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

enimiste/knp-menu-laravel
=========================

Laravel package to create navigation menus, based on KnpLabs/KnpMenu. Fork of dowilcox/KnpMenu-Laravel package

2.2.2(9y ago)06472MITPHP

Since Mar 3Pushed 9y ago1 watchersCompare

[ Source](https://github.com/enimiste/KnpMenu-Laravel)[ Packagist](https://packagist.org/packages/enimiste/knp-menu-laravel)[ RSS](/packages/enimiste-knp-menu-laravel/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (9)Used By (2)

KnpMenu-Laravel
===============

[](#knpmenu-laravel)

Laravel 5 package to create navigation menus, based on [KnpLabs/KnpMenu](https://github.com/KnpLabs/KnpMenu).

### Installation

[](#installation)

Add to your composer.json file

```
"enimiste/knp-menu-laravel": "2.*"
```

### Register the package

[](#register-the-package)

In config/app.php add the service provider and alias.

```
Dowilcox\KnpMenu\MenuServiceProvider::class,
```

```
'Menu' => Dowilcox\KnpMenu\Facades\Menu::class,
```

To Access the menu service directly :

```
$menu_builder = app('knp_menu.menu');
```

#### Publish config

[](#publish-config)

```
php artisan vendor:publish --tag=knp_menu
```

### Custom Rendrer

[](#custom-rendrer)

To define your custom renderer :

- Implements the interface "Knp\\Menu\\Renderer\\RendererInterface"
- Register a binding to "knp\_menu.renderer" that returns a new instance of your new custom renderer. To get the matcher use `$app["knp_menu.matcher"]`

### Custom Voter

[](#custom-voter)

To add custom Voter you implement the interface "Dowilcox\\KnpMenu\\Voter\\OrderedVoterInterface" and register it in the service container with the tag "knp\_menu.voter"
Set the lower order for Voter that should be executed in first.
It is recommended order values between 0 and than 100.
Your Voters will be executed first before the built in ones.

- RouteNameVoter (100)
- UriVoter (200 and 300)

### Blade directives

[](#blade-directives)

- @rendermenu("main" \[, {"firstClass":"first2","lastClass":"last2"}\]) or @rendermenu("main" \[, "config\_name"\]): It renders the menu defined by the name "menu\_name". It is a shortcut to `echo \Menu::render(\Menu::get('menu_name'))`
- @menu('menu\_name') .... @endmenu : between these two directives you have access to a variable named `$menu` holding the menu defined by the name "menu\_name". This object is an instance of `Knp\Menu\MenuItem`

### Example

[](#example)

```
$menu = Menu::create('main-menu', ['childrenAttributes' => ['class' => 'nav']]);

/*
* This is the list of possible options for a menu item :
*
*     'uri' => null,
*     'label' => null,
*     'attributes' => array(),
*     'linkAttributes' => array(),
*     'childrenAttributes' => array(),
*     'labelAttributes' => array(),
*     'extras' => array(),
*     'current' => null,
*     'display' => true,
*     'displayChildren' => true,
*/

$menu->addChild('Home', [
'uri' => url('/'),
'attributes' => [
    'class'=>'your_css_class',
 ],
 'extras' => [
    'routes' => [
        ['route' => 'route_name_1'],
        ['route' => 'route_name_2'],
    ]
 ]
]);
$menu->addChild('Users', ['uri' => route('admin.users.index')]);
$menu->addChild('Roles', ['uri' => route('admin.roles.index')]);
$menu->addChild('Menu', ['uri' => url('menu')]);

echo Menu::render($menu);
//Or
echo Menu::render($menu, $custom_render_options);//$custom_render_options is an array
```

Will output:

```

    Home

    Users

    Roles

    Menu

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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 ~90 days

Recently: every ~0 days

Total

8

Last Release

3508d ago

Major Versions

0.0.1 → 1.0.02015-03-13

1.0.1 → 2.0.12016-11-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/43e7310829d4711c88c34476daec986374515494fa1db2893f33d9091cc25a1a?d=identicon)[nouni.elbachir](/maintainers/nouni.elbachir)

---

Top Contributors

[![dowilcox](https://avatars.githubusercontent.com/u/1311943?v=4)](https://github.com/dowilcox "dowilcox (16 commits)")[![enimiste](https://avatars.githubusercontent.com/u/2515677?v=4)](https://github.com/enimiste "enimiste (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/enimiste-knp-menu-laravel/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M337](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M131](/packages/laravel-mcp)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k12](/packages/laravel-surveyor)[webcrafts-studio/lens-for-laravel

A plug-and-play accessibility auditor for Laravel.

371.4k](/packages/webcrafts-studio-lens-for-laravel)

PHPackages © 2026

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