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

ActiveLibary

red-freak/laravel-menu
======================

A Laravel Facade to generate Menus.

0.0.1-alpha(2y ago)12[4 PRs](https://github.com/red-freak/laravel-menu/pulls)MITPHPPHP ^8.0

Since Oct 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/red-freak/laravel-menu)[ Packagist](https://packagist.org/packages/red-freak/laravel-menu)[ GitHub Sponsors](https://github.com/red-freak)[ RSS](/packages/red-freak-laravel-menu/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (6)Used By (0)

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

[](#laravel-menu)

Laravel Menu is a package to create menus for laravel applications. It's a package to also solve the problem for module based applications (see [red-freak/laravel-modules](https://github.com/red-freak/laravel-modules)).

[![Latest Version](https://camo.githubusercontent.com/34db8382964315ff1ec0687845b32dd44fefe422991cadf80d248fd4b0e810d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7265642d667265616b2f6c61726176656c2d6d656e752e737667)](https://github.com/red-freak/laravel-menu/releases)[![MIT Licensed](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![run-tests](https://camo.githubusercontent.com/8cf20c30b1e25944da96753ff7dde49b534340d6b336df6e7f49d93e8e3effc0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7265642d667265616b2f6c61726176656c2d6d656e752f6c61726176656c2e796d6c3f6c6162656c3d7465737473)](https://github.com/red-freak/laravel-menu/actions)[![Total Downloads](https://camo.githubusercontent.com/33ded84c47e7939289035ec68deb0fdaa05137d41cc8f61628ea2c3df8241b9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7265642d667265616b2f6c61726176656c2d6d656e752e737667)](https://packagist.org/packages/spatie/browsershot)[![Total Downloads](https://camo.githubusercontent.com/33ded84c47e7939289035ec68deb0fdaa05137d41cc8f61628ea2c3df8241b9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7265642d667265616b2f6c61726176656c2d6d656e752e737667)](https://packagist.org/packages/spatie/browsershot)

[![Supported PHP Version](https://camo.githubusercontent.com/0fde9b4341830e44978c19166b67395f2eaf93372d036d770f93ff996dcba328/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f382e30253243253230382e31253243253230382e322d3535353f6c6f676f3d706870)](https://camo.githubusercontent.com/0fde9b4341830e44978c19166b67395f2eaf93372d036d770f93ff996dcba328/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f382e30253243253230382e31253243253230382e322d3535353f6c6f676f3d706870)[![Supported Laravel Version](https://camo.githubusercontent.com/3cde9bd1f98d5094043e2704535ed3f9376fb9a646a43196a9cb9f781b0b2e46/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f382e78253243253230392e7825324325323031302e782d3535353f6c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/3cde9bd1f98d5094043e2704535ed3f9376fb9a646a43196a9cb9f781b0b2e46/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f382e78253243253230392e7825324325323031302e782d3535353f6c6f676f3d6c61726176656c)

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

[](#installation)

Simply install the package via composer:

```
composer require red-freak/laravel-menu
```

How to use
----------

[](#how-to-use)

### Basic usage

[](#basic-usage)

The base idea is to be able to create or add items via a `Menu`-Facade. It can be accessed from anywhere. So you are able to have different (e.g. module-bases) ServiceProviders to do so.

```
Menu::add('home')
    ->add(new Item('Home', '/'))
    ->add(new Item('About', '/about'))
    ->add(new Item('Login', '/login'));
```

```

    Home

    About

    Login

```

### Add items to a menu

[](#add-items-to-a-menu)

You can define the menus in the config file for later use in your project and can also add items to a menu via the `Menu`-Facade. And of course it can work with labels.

```
// define the menu anywhere to use translation keys as labels (or do it by config)
Menu::add('home', [
    RenderOptions::KEY_USE_LABELS_AS_TRANSLATION_KEYS => true
]);

...

// have the corresponding translation keys via files (or in this case via the `Translator`-Facade)
app()->translator->addLines([
    'menu.label.home' => 'Home',
    'menu.label.about' => 'About',
    'menu.label.login' => 'Login',
], 'en');

...

// Now you can add items via the `Item` class ...
Menu::get('home')
    ->add(new Item('menu.label.home', 'http://localhost'))
    ->add(new Item('menu.label.about', 'http://localhost/about'))
    ->add(new Item('menu.label.login', 'http://localhost/login'));

// ... or add them via key-value ...
Menu::get('home')
    ->add([
        Menu::KEY_ITEM_LABEL => 'Home',
        Menu::KEY_ITEM_LINK => 'http://localhost',
    ])
    ->add([
        Menu::KEY_ITEM_LABEL => 'About',
        Menu::KEY_ITEM_LINK => 'http://localhost/about',
    ])
    ->add([
        Menu::KEY_ITEM_LABEL => 'Login',
        Menu::KEY_ITEM_LINK => 'http://localhost/login',
    ]);

// ... or add them via routes ...
// Route::get('/', fn() => 'home')->name('home');
// Route::get('/about', fn() => 'about')->name('about');
// Route::get('/login', fn() => 'login')->name('login');
Menu::get('home')
    ->add([Menu::KEY_ITEM_ROUTE => 'home'])
    ->add([Menu::KEY_ITEM_ROUTE => 'about'])
    ->add([Menu::KEY_ITEM_ROUTE => 'login']);
```

If you now call `Menu::home()` via the automatically create macro, you will get the following result:

```

    Home

    About

    Login

```

### Add a submenu for a Model

[](#add-a-submenu-for-a-model)

```
// define the route and the translation keys
Route::resource('users', Controller::class);
app()->translator->addLines([
    'menu.label.users.index' => 'Users',
    'menu.label.users.create' => 'create User',
], 'en');
```

```
// define the menu and add a submenu by a model
Menu::add('home', [RenderOptions::KEY_USE_LABELS_AS_TRANSLATION_KEYS => true])->add([
    Menu::KEY_ITEM_MODEL => User::class,
]);
```

If you now call `Menu::home()` via the automatically create macro, you will get the following result:

```

    Users

        Users

        create User

```

run tests
---------

[](#run-tests)

`vendor/bin/pest --coverage-html ./tests/reports/pest`

special thanks
--------------

[](#special-thanks)

- [Spatie](https://github.com/spatie) for general inspiration on package development and their workflows

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

949d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba07c0dca0bf37238cb052349b522be81c50a0d3c495d341c31a6435ee889cb1?d=identicon)[red-freak](/maintainers/red-freak)

---

Top Contributors

[![red-freak](https://avatars.githubusercontent.com/u/66564761?v=4)](https://github.com/red-freak "red-freak (26 commits)")

###  Code Quality

TestsPest

### Embed Badge

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

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

PHPackages © 2026

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