PHPackages                             fbf/laravel-navigation - 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. fbf/laravel-navigation

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

fbf/laravel-navigation
======================

A Laravel 4 package for adding multiple, database driven, menus to a site

v0.2.0(12y ago)134426[6 issues](https://github.com/FbF/Laravel-Navigation/issues)MITPHPPHP &gt;=5.3.0

Since Jan 14Pushed 12y ago9 watchersCompare

[ Source](https://github.com/FbF/Laravel-Navigation)[ Packagist](https://packagist.org/packages/fbf/laravel-navigation)[ RSS](/packages/fbf-laravel-navigation/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Laravel Navigation
==================

[](#laravel-navigation)

A Laravel 4 package for adding multiple, database driven, hierarchical menus to a site

Features
--------

[](#features)

Comes with:

- Migration for the 'nav\_items' table (includes fields for adding custom CSS class to an item, and 'descendant routes', which allow you to add route patterns which trigger things like the active\_child class if the current route is effectively be a child of the current item, but there is no node in the database for the current route, e.g. you have a nav item called 'Blog' (which is routed through to your BlogController@index method) but not one for each individual Blog Post. Adding the route for the BlogPostController@view method to this field, e.g. 'blog/{slug}' will ensure the Blog menu item has the active child class, when you are viewing the Blog Post)
- NavItem Model (that extends Baum/Node)
- View Composer for generating all the menus
- Sample FrozenNode/Administrator config file for managing the nav\_items

Menus can be traditional nested list style (e.g. multiple nested `ul` and `li` tags), or drop downs (`select` and `option` tags, where the value in child node `option` tags are prefixed with a string e.g. spaces or '..' repeated according to the node's depth).

Once you've set up the hierarchy in the database, you can configure multiple menus to be generated from that single hierarchy. Different menus can include the same nodes, but used in different pages of your site, or different places on the same pages.

For each menu, you can control

- The minimum and maximum (or no maximum) depth of items within that branch of the hierarchy to include in the menu
- Whether to show children: \*\* always (useful for always expanded, or fly-out/dynamic/JavaScript menus for example, consider using in combination with the `max_depth` option) \*\* or only when the current item is in that branch of the hierarchy, or it has children (useful for sidebar, section based navigation)

Menu items automatically include useful CSS classes to achieve common styling enhancements, such as:

- First item in the level
- Last item in the level
- Currently active item
- A child of this item is currently active
- Item has children

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

[](#installation)

Add the following to you composer.json file

```
"fbf/laravel-navigation": "dev-master"

```

Run

```
composer update

```

Add the following to app/config/app.php

```
'Fbf\LaravelNavigation\LaravelNavigationServiceProvider'

```

Publish the config

```
php artisan config:publish fbf/laravel-navigation

```

Run the migration

```
php artisan migrate --package="fbf/laravel-navigation"

```

Ensure the navigation `types` are set correctly in the config file. See the config file for comprehensive examples

Run the seed (this will create root nodes for each of your navigation `types`)

```
php artisan db:seed --class="Fbf\LaravelNavigation\NavItemsTableSeeder"

```

Build your menus in the database, or if you are using FrozenNode's Laravel Administrator, see the info below

Usage
-----

[](#usage)

The package comes with a View Composer which you can attach to any view in your app. E.g.

```
// app/routes.php
View::composer('layouts.master', 'Fbf\LaravelNavigation\NavigationComposer');

```

This is responsible for generating your menu data.

Now to render the menus, you just need to do the following in your view:

```
{{ $MainNavigation }}

```

This will render the 'Main' menu. If you had configured another menu called 'Footer', you would render this by adding the following to your view:

```
{{ $FooterNavigation }}

```

Basically, whatever `types` you set up in the config file, that type's menu is in a view variable called "&lt; type &gt;Navigation".

If you need to a output a menu in a view file but you've attached the composer to a layout, e.g. you want to render a sidebar menu inside the pages.view view file, the $SidebarNavigation variable won't be available since the composer won't have executed yet, it runs when the master layout is rendered, which happens after your view. In this case, just attach the composer to the pages.view view as well as the layout. The view composer won't create them again. E.g.

```
View::composer(array(
	'layouts.master',
	'laravel-pages::page',
), 'Fbf\LaravelNavigation\NavigationComposer');
```

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

[](#configuration)

A sample config file is supplied which you can amend, after publishing into your app, to suit your app's navigation requirements.

In addition to the options listed there, you can also pass in any of the following, for each menu:

```
	protected $defaultOptions = array(
		'from_depth' => 1,
		'from_item_id' => null,
		'max_depth' => null,
		'root_element' => 'div',
		'root_element_class' => 'menu',
		'root_element_type_class_prefix' => 'menu--',
		'list_element' => 'ul',
		'root_list_class' => '',
		'current_item_content_element' => 'span',
		'item_content_depth_prefix' => '..',
		'item_element' => 'li',
		'item_class' => '',
		'active_child_class' => 'menu--item__selected-child',
		'active_class' => 'menu--item__selected',
		'first_class' => 'menu--item__first',
		'last_class' => 'menu--item__last',
		'has_children_class' => 'menu--item__has-children',
	);
```

Administrator
-------------

[](#administrator)

You can use the excellent Laravel Administrator package by frozennode to administer your pages.

A ready-to-use model config file for the `NavItem` model (`navigation.php`), including custom actions to reorder nodes in the hierarchy, is provided in the `src/config/administrator` directory of the package, which you can copy into the `app/config/administrator` directory (or whatever you set as the `model_config_path` in the administrator config file).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~24 days

Total

4

Last Release

4478d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1890fa7f83fd77b7c73d984199cb9a45ba9871acb4133490f43115c19fe845f?d=identicon)[neilcrookes](/maintainers/neilcrookes)

---

Top Contributors

[![neilcrookes](https://avatars.githubusercontent.com/u/24232?v=4)](https://github.com/neilcrookes "neilcrookes (9 commits)")[![danclaydon](https://avatars.githubusercontent.com/u/8693957?v=4)](https://github.com/danclaydon "danclaydon (1 commits)")[![noxify](https://avatars.githubusercontent.com/u/521777?v=4)](https://github.com/noxify "noxify (1 commits)")[![zenekp](https://avatars.githubusercontent.com/u/2039101?v=4)](https://github.com/zenekp "zenekp (1 commits)")

### Embed Badge

![Health badge](/badges/fbf-laravel-navigation/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M267](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M991](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M363](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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