PHPackages                             sirgrimorum/automenu - 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. sirgrimorum/automenu

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

sirgrimorum/automenu
====================

Smart menu form Laravel 5.6

1.3.4(2mo ago)1271↓50%MITPHPPHP ^8.2CI failing

Since Feb 28Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/sirgrimorum/automenu)[ Packagist](https://packagist.org/packages/sirgrimorum/automenu)[ Docs](https://github.com/sirgrimorum/automenu)[ RSS](/packages/sirgrimorum-automenu/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (36)Used By (0)

AutoMenu
========

[](#automenu)

[![Latest Version on Packagist](https://camo.githubusercontent.com/22d71de138d5ffa2d658e2c4bcce26487b408ea551a39cce1e9b11785f387af5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/22d71de138d5ffa2d658e2c4bcce26487b408ea551a39cce1e9b11785f387af5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)[![PHP Version](https://camo.githubusercontent.com/e4f6beeb95ac0f8a2035fb38b0c9214541de26c5172b876d0c343c326fe85399/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e4f6beeb95ac0f8a2035fb38b0c9214541de26c5172b876d0c343c326fe85399/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/bd590e5e183d43e18b7045cc5f2ccb61c7180069ef1335f57a942c253f534d60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/bd590e5e183d43e18b7045cc5f2ccb61c7180069ef1335f57a942c253f534d60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/cbe6a28d37ebf73571f79e60f016b3f189ffc0812f5aa7c409ddb954c7e9297d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/cbe6a28d37ebf73571f79e60f016b3f189ffc0812f5aa7c409ddb954c7e9297d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7369726772696d6f72756d2f6175746f6d656e752e7376673f7374796c653d666c61742d737175617265)

A dynamic, hierarchical Bootstrap navigation builder for Laravel. Generate full multi-level navbars from PHP configuration arrays — with user data interpolation, locale-aware links, access control, and zero HTML boilerplate.

Features
--------

[](#features)

- **No HTML required** — generate a complete Bootstrap navbar from a configuration array
- **Multi-level dropdowns** — unlimited nesting depth
- **User data interpolation** — embed `{name}`, `{email}`, or any user attribute/method into labels and URLs
- **Dynamic value prefixes** — `__route__`, `__url__`, `__trans__`, `__asset__`, `__getLocale__` are evaluated at render time
- **Per-item access control** — closures, `Auth::check()`, or the `"na"` (always-visible) constant
- **Blade stack injection** — push extra items into the menu at render time via named stacks
- **Fully configurable styling** — every Bootstrap class (navbar, brand, nav, items, dropdowns) is overridable in config

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

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 9.0

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

[](#installation)

```
composer require sirgrimorum/automenu
```

### Publish configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="Sirgrimorum\AutoMenu\AutoMenuServiceProvider" --tag=config
```

Publishes `config/sirgrimorum/automenu.php`.

### Publish views (optional)

[](#publish-views-optional)

```
php artisan vendor:publish --provider="Sirgrimorum\AutoMenu\AutoMenuServiceProvider" --tag=views
```

Publishes to `resources/views/vendor/sirgrimorum/automenu/`.

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

[](#configuration)

`config/sirgrimorum/automenu.php`

### Blade stacks

[](#blade-stacks)

Items pushed onto these stacks are injected into the rendered navbar:

```
'menu_stack'              => 'menuobj',    // main injection stack
'menuitem_izquierda_stack' => 'menuleft',  // left nav items
'menuitem_derecha_stack'   => 'menuright', // right nav items
```

### Bootstrap classes

[](#bootstrap-classes)

```
'classes' => [
    'navbar'        => 'navbar navbar-expand-md navbar-dark bg-dark',
    'brand'         => 'navbar-brand',
    'nav_izquierda' => 'navbar-nav mr-auto',
    'nav_derecha'   => 'navbar-nav ml-auto',
    'item'          => 'nav-item',
    'link'          => 'nav-link',
    'dropdown'      => 'nav-item dropdown',
    'dropdown_menu' => 'dropdown-menu',
    'dropdown_item' => 'dropdown-item',
    'button'        => 'btn btn-outline-light',
],
```

### User field replacements

[](#user-field-replacements)

Placeholders in labels and URLs are replaced with values from `Auth::user()`:

```
'replaces' => [
    '{name}'  => 'name',       // property access
    '{email}' => 'email',
    '{image}' => 'getAvatar',  // method call if callable
],
```

### Dynamic value prefixes

[](#dynamic-value-prefixes)

PrefixResolves to`__route__routeName``route('routeName')``__url__/path``url('/path')``__trans__key``trans('key')``__asset__path/file.js``asset('path/file.js')``__getLocale__``App::getLocale()`Defining a Menu
---------------

[](#defining-a-menu)

The menu structure is a PHP array with three sections: `top`, `izquierdo` (left), and `derecha` (right). Store it in a config file or a translation file.

```
// config/sirgrimorum/menus/main.php
return [
    'top'       => [],
    'izquierdo' => [
        [
            'label'  => '__trans__nav.home',
            'url'    => '__route__home',
            'access' => 'na',                          // always visible
        ],
        [
            'label'    => '__trans__nav.admin',
            'url'      => '#',
            'access'   => fn() => Auth::user()?->isAdmin(),
            'children' => [
                [
                    'label' => '__trans__nav.users',
                    'url'   => '__route__admin.users.index',
                ],
            ],
        ],
    ],
    'derecha' => [
        [
            'label'  => 'Hello, {name}',
            'url'    => '__route__profile',
            'access' => fn() => Auth::check(),
        ],
        [
            'label'  => '__trans__nav.login',
            'url'    => '__route__login',
            'access' => fn() => !Auth::check(),
        ],
    ],
];
```

Usage
-----

[](#usage)

### Blade directive

[](#blade-directive)

```
{{-- render with explicit id, config path, and menu structure --}}
@load_automenu('main-nav', 'sirgrimorum/menus/main')

{{-- all three parameters are optional; falls back to config defaults --}}
@load_automenu()
```

### Facade

[](#facade)

```
{!! AutoMenu::buildAutoMenu('main-nav', 'sirgrimorum/menus/main') !!}
```

### Injecting extra items at runtime

[](#injecting-extra-items-at-runtime)

In any view rendered before the menu layout:

```
@push('menuobj')

        Cart ({{ $cartCount }})

@endpush
```

### Integration with sirgrimorum/pages

[](#integration-with-sirgrimorumpages)

```
use Sirgrimorum\Pages\Pages;

$menuWithPages = Pages::getAutoMenuConfig(2, 'izquierdo', config('sirgrimorum/menus/main'));
echo AutoMenu::buildAutoMenu('main-nav', '', $menuWithPages);
```

API Reference
-------------

[](#api-reference)

### `AutoMenu::buildAutoMenu()`

[](#automenubuildautomenu)

```
AutoMenu::buildAutoMenu(
    string $id       = 'menu',  // HTML id for the  element
    mixed  $config   = '',      // Config array or dot-path string to a config file
    mixed  $automenu = ''       // Menu structure array or translation key
): string
```

Returns the full Bootstrap navbar HTML string.

### `AutoMenu::replaceUser()`

[](#automenureplaceuser)

```
AutoMenu::replaceUser(string $string, mixed $config = ''): string
```

Replaces `{field}` placeholders in `$string` with values from the authenticated user.

### `AutoMenu::hasAccess()`

[](#automenuhasaccess)

```
AutoMenu::hasAccess(mixed $rule): bool
```

Evaluates an access rule: `'na'` → always `true`; `callable` → invokes it; otherwise returns `Auth::check()`.

### Blade directive

[](#blade-directive-1)

```
@load_automenu(string $id = 'menu', mixed $config = '', mixed $automenu = '')
```

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md).

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

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 ~86 days

Recently: every ~1 days

Total

35

Last Release

78d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.0

1.3.0PHP ^8.0

1.3.3PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/38ced8f27be30def379c1900bf2a56c7e682180f6a693f17d8168e4e74b8ca82?d=identicon)[sirgrimorum](/maintainers/sirgrimorum)

---

Tags

sirgrimorumautomenu

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sirgrimorum-automenu/health.svg)

```
[![Health](https://phpackages.com/badges/sirgrimorum-automenu/health.svg)](https://phpackages.com/packages/sirgrimorum-automenu)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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