PHPackages                             coreplex/navigator - 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. coreplex/navigator

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

coreplex/navigator
==================

A framework agnostic navigation package that handles active states and permissions for navigation items

v0.1.5(8y ago)1297MITPHPPHP &gt;=5.4.0

Since Apr 8Pushed 7y ago3 watchersCompare

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

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Navigator [![Build Status](https://camo.githubusercontent.com/f8e4e036f0ed5746780a177c4a290ea8aea4dc45742b1e346b03c4c97ac0c1df/68747470733a2f2f7472617669732d63692e6f72672f636f7265706c65782f6e6176696761746f722e737667)](https://travis-ci.org/coreplex/navigator) [![Latest Stable Version](https://camo.githubusercontent.com/e987375011041ad3d0f49d401a37a5b4f471f858cf1da9b76439bc4bd4731ed2/68747470733a2f2f706f7365722e707567782e6f72672f636f7265706c65782f6e6176696761746f722f762f737461626c65)](https://packagist.org/packages/coreplex/navigator) [![License](https://camo.githubusercontent.com/7b22050da1979921cee1da5f13bfcea6b5cce94062d737a188e6c8e78b52ce52/68747470733a2f2f706f7365722e707567782e6f72672f636f7265706c65782f6e6176696761746f722f6c6963656e7365)](https://packagist.org/packages/coreplex/navigator)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#navigator---)

A PHP 5.4+ package to create navigation menus, and handle active and permissions.

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

[](#installation)

This package requires PHP 5.4+, and includes a Laravel 5 Service Provider and Facade.

We recommend installing the package through composer. You can either call `composer require coreplex/navigator` in your command line, or add the following to your `composer.json` and then run either `composer install` or `composer  update` to download the package.

```
"coreplex/navigator": "~0.1"
```

### Laravel 5 Integration

[](#laravel-5-integration)

To use the package with Laravel 5 firstly add the service providers to the list in `app/config/app.php`.

```
'providers' => array(

  Coreplex\Core\CoreServiceProvider::class,
  Coreplex\Navigator\NavigatorServiceProvider::class,

);
```

Then to run `php artisan vendor:publish` in your command line to publish the config.

Registering Menus
-----------------

[](#registering-menus)

To register a menu you add it into the `menus` array in the navigator config file. To register a menu you set a key to retrieve a the menu by as the key, and the class to build the menu as the value.

```
'menus' => [
  'foo' => 'Navigators\FooNavigator'
]
```

By default the menu class will user a method called `design`, but if you want to set the method name your self just separate the class and method name with an @ symbol.

```
'menus' => [
  'foo' => 'Navigators\FooNavigator@bar'
]
```

To see how to create menus check the [creating menus](#creating-menus) section below.

Retrieving Menus
----------------

[](#retrieving-menus)

Once you've registered a menu to retrieve it use the `get` method.

```
$menu = $navigator->get('foo');
```

Creating Menus
--------------

[](#creating-menus)

To create a menu you need to return a nested array of menu items. Each item is made up of a url, any nested menu items, and then any attributes wish the item to have. As an example check the code below.

```
class Sidebar
{
  public function design()
  {
    return [
      [
        'url' => '/',
        'title' => 'Home',
      ],
      [
        'url' => 'about',
        'title' => 'about',
        'items' => [
          [
            'url' => 'meet-the-team',
            'title' => 'Meet The Team'
          ]
        ]
      ]
    ];
  }
}
```

This will add two items to then menu; one for the home page and the other is the about page. The about page also has nested items so we can display them in a drop down when rendering.

The url isn't required, but is used to check if the item is the active item.

You can add any attributes you wish to the menu items. In the example a title attribute has been set, but we could also add an icon, class etc. here and then access it on the item when it is rendered.

### Filters

[](#filters)

Occasionally you may need to only show a menu item if a condition is met; to do this with use filters.

To register a filter add it to the filters array in the config file by setting a unique key as a the key and a class to use as the value.

```
'filters' => [
  'hasAccess' => 'Navigators\Filters\HasAccess'
]
```

The filter classes by default use a method called `filter` but again if you want to specify a method then separate the class and method with an @ symbol.

```
'filters' => [
  'hasAccess' => 'Navigators\Filters\HasAccess@foo'
]
```

To call a filter no a menu item add a filter attribute to the menu item.

```
[
  'url' => '/admin',
  'title' => 'admin',
  'filter' => 'hasAccess',
  'permission' => 'admin.access',
],
```

The method on the filter class will then be passed the item so you can do any checking you need to.

```
use Coreplex\Navigator\Contracts\Item;

class HasAccess
{
  public function filter(Item $item)
  {
    if ($user->canAccess($item->permission) {
      return true;
    }

    return false;
  }
}
```

Rendering Menus
---------------

[](#rendering-menus)

To render a menu you have a couple of options. Either you can set a template to render it to, or you can access the menus properties.

### Rendering With a Template

[](#rendering-with-a-template)

To render with a template simply call the `render` method on the menu. This will either use the default view set in the config file, or you can pass the path to the template to use to the render method.

```
$menu = $navigator->get('foo');

$menu->render();
$menu->render('path/to/template.php');
```

This package comes with a default template as an example.

### Rendering From the Menu

[](#rendering-from-the-menu)

To access the items in a menu use the `items` method or just pass the menu through a iterator.

```
$items = $menu->items();

OR

foreach ($menu as $item) {
  //
}
```

Then once you've got a menu item you can can check if it is the active menu item by calling the `isActive` method.

```
$item->isActive();
```

Then you can access any properties set on the item by just accessing the key on the item object. For example if you have set a url for the item then I could do the following.

```
$item->url;
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.1% 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 ~222 days

Recently: every ~236 days

Total

6

Last Release

2947d ago

### Community

Maintainers

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

---

Top Contributors

[![michaeljennings](https://avatars.githubusercontent.com/u/5189701?v=4)](https://github.com/michaeljennings "michaeljennings (35 commits)")[![georgehanson](https://avatars.githubusercontent.com/u/23167178?v=4)](https://github.com/georgehanson "georgehanson (1 commits)")[![jakewtaylor](https://avatars.githubusercontent.com/u/8126758?v=4)](https://github.com/jakewtaylor "jakewtaylor (1 commits)")[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (1 commits)")

---

Tags

laravelnavigation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coreplex-navigator/health.svg)

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

###  Alternatives

[caffeinated/menus

Laravel Menus

134159.5k5](/packages/caffeinated-menus)[kodicomponents/navigation

The KodiCMS Support package.

12232.6k10](/packages/kodicomponents-navigation)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[rinvex/laravel-menus

Rinvex Menus is a simple menu builder package for Laravel, that supports hierarchical structure, ordering, and styling with full flexibility using presenters for easy styling and custom structure of menu rendering.

294.0k20](/packages/rinvex-laravel-menus)

PHPackages © 2026

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