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

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

rspeekenbrink/laravel-menu
==========================

Simple menu generation in Laravel

1.5.0(2mo ago)164.5k↑106.3%4MITPHPPHP ^7.2|^8.0CI passing

Since Oct 9Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/RSpeekenbrink/laravel-menu)[ Packagist](https://packagist.org/packages/rspeekenbrink/laravel-menu)[ RSS](/packages/rspeekenbrink-laravel-menu/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (14)Versions (16)Used By (0)

Laravel Menu
============

[](#laravel-menu)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9214f69564f01135f0ada21bfa9cadb590f49b7c9f59498dbf06a03db70f679d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72737065656b656e6272696e6b2f6c61726176656c2d6d656e752e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rspeekenbrink/laravel-menu)[![Total Downloads](https://camo.githubusercontent.com/7fb8126126c526c795726cc83b79fbddc1fda350ee4ea59c45957a5c87eca935/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72737065656b656e6272696e6b2f6c61726176656c2d6d656e752e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rspeekenbrink/laravel-menu)

Create menu objects server-sided without sweat for Front-End adoption.

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

[](#installation)

You can install the package via composer:

```
composer require rspeekenbrink/laravel-menu
```

Usage
-----

[](#usage)

A default menu will already be registered and bound to the `Menu` facade. You can add items to the menu like this:

```
Menu::add('itemName', '/');

// Menu::toArray() Output:
[
    [
        'name' => 'itemName',
        'route' => '/',
        'active' => true,
    ]
]
```

**The itemName should be unique within the menu since this is the identifier of the item in the Menu.**

### Route attribute and Active state

[](#route-attribute-and-active-state)

The route can be an absolute route like `'/dashboard/profile'` or a name of a route like `'dashboard.index'` for the automatic active state checking to work properly. If you want to use route names we recommend you to use [Ziggy](https://github.com/tightenco/ziggy) to convert the names to URLs in your front-end.

The active attribute is a boolean that will be true if the route matches the route of the current request (path or name wise).

### Nested Routes

[](#nested-routes)

To create nested items you could use the following:

```
Menu::add('dashboard', '/')->addChildren(function () {
    Menu::add('stats', '/stats');
    Menu::add('profile', '/profile');
});

// Menu::toArray() Output:
[
    [
        'name' => 'dashboard',
        'route' => '/',
        'active' => true,
        'children' => [
            [
                'name' => 'dashboard.stats',
                'route' => '/stats',
                'active' => false,
            ],
            [
                'name' => 'dashboard.profile',
                'route' => '/profile',
                'active' => false,
            ]
        ]
    ]
]
```

### Attributes

[](#attributes)

You can pass attributes to the MenuItem to define values like Title or anything else you desire;

```
Menu::add('itemName', '/', ['title' => 'Dashboard', 'someAttribute' => 231, 'another' => 'value2']);

// Menu::toArray() Output:
[
    [
        'name' => 'itemName',
        'route' => '/',
        'active' => true,
        'title' => 'Dashboard',
        'someAttribute' => 231,
        'another' => 'value2,
    ]
]
```

### Adding items condition wise or via Auth Guards

[](#adding-items-condition-wise-or-via-auth-guards)

If you would like to add menu items conditionwise, for example only add a menu item if a user is logged in, you can do it like this:

```
Menu::addIf($conditionOrClosure, 'itemName', $route, $attributes);
```

Or pass a Auth Guard:

```
Menu::addIfCan('MyAuthGuard', 'itemName', $route, $attributes);
```

### Usage with InertiaJS

[](#usage-with-inertiajs)

The main purpose of this package is to create Menu objects that can be adopted easily by the Front-End. One of the easiest ways to transfer the objects from the back to the front is by using [InertiaJS](https://inertiajs.com/).

```
Inertia::share([
    'menu' => function () {
        return Menu::toArray();
    }
]);
```

Then for example in your inertia-vue layout template;

```

                     {{ item.title }}

                      {{ child.title }}

```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 93.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 ~198 days

Recently: every ~289 days

Total

13

Last Release

75d ago

Major Versions

0.4.0 → 1.0.02020-09-11

PHP version history (2 changes)0.1.0PHP ^7.2

1.0.1PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e272af6fe1744b2ffed9a88bf195543e3070cf14f941a394572231a84893dbe?d=identicon)[RSpeekenbrink](/maintainers/RSpeekenbrink)

![](https://avatars.githubusercontent.com/u/31687602?v=4)[Lex de Willigen](/maintainers/lexdewilligen)[@lexdewilligen](https://github.com/lexdewilligen)

---

Top Contributors

[![RSpeekenbrink](https://avatars.githubusercontent.com/u/7093216?v=4)](https://github.com/RSpeekenbrink "RSpeekenbrink (72 commits)")[![lexdewilligen](https://avatars.githubusercontent.com/u/31687602?v=4)](https://github.com/lexdewilligen "lexdewilligen (4 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

front-endjavascriptlaravelmenu

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M203](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)

PHPackages © 2026

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