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

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

bkoetsier/navigation
====================

1.0(12y ago)069[1 issues](https://github.com/bastiankoetsier/navigation/issues)MITPHPPHP &gt;=5.4.0

Since May 6Pushed 12y agoCompare

[ Source](https://github.com/bastiankoetsier/navigation)[ Packagist](https://packagist.org/packages/bkoetsier/navigation)[ RSS](/packages/bkoetsier-navigation/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/5bf8f03ae2d65d4c960f99af62fa1401018a744e1282da7cc51aa1a25439d608/68747470733a2f2f7472617669732d63692e6f72672f6261737469616e6b6f6574736965722f6e617669676174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bastiankoetsier/navigation)

Navigation
==========

[](#navigation)

After filling the navigation with your menu / breadcrumb - information (e.g. categories or whatever), you´re able to create a fully rendered HTML list.

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

[](#installation)

Pull in the package with composer:

```
{
    "require": {
                "bkoetsier/navigation": "1.0.*"
                }
}
```

### Laravel user

[](#laravel-user)

If you´re using the Laravel framework, all you have to do is reference the service provider and you are ready to go !

```
// app/config/app.php

'providers' => [
    '...',
    'Bkoetsier\Navigation\Providers\Laravel\NavigationServiceProvider',
];
```

### Without Laravel

[](#without-laravel)

If you aren´t using Laravel, you have to wire up the package yourself:

```
use Bkoetsier\Navigation\Navigation;
use Illuminate\Support\Collection;

$nav = new Navigation(new Bucket(new Collection));
```

> In case of using Laravel Navigation is shared via the IoC Container, so if you hydrate a bucket once, the bucket will be available all over your app, but the main difference is in instantiation

#### Basic usage

[](#basic-usage)

First step is always hydrating the bucket. To do so, you have to provide an array of objects (preferably `StdClass`) with the following properties:

- `itemId` unique identifier like the database index
- `itemContent` the content that should be rendered for this item
- `parentId` identifier of the parent

In the `fill` method you are able to rename each parameter to your corresponding properties :

```
$example = [
    [
        "id": 1,
        "content": 'Books',
        "parent": null,
    ],
    [
        "id": 2,
        "content": 'Fiction',
        "parent": 1,
    ]
];
```

```
// array to \Std
$data = json_decode(json_encode($example));

// with Laravel
Nav::fill($data, $itemIdentifier = 'id', $itemContent ='content',$parentIdentifier = 'parent');

//without Laravel
$nav->fill($data, $itemIdentifier = 'id', $itemContent = 'content',$parentIdentifier = 'parent');
```

After hydrating you have to set the current item-id and call the `render`-method:

```
//with Laravel
// set the current active item-id, maybe from a url or db
Nav::setCurrent(2);
Nav::menu('main')->render();

//without Laravel
$nav->setCurrent(2);
$nav->menu('main')->render();
```

> Attention: when you use `php Nav::setCurrent()` it will be set for each menu you have defined !

will output:

```

    Books

        Fiction

```

> Please note that the current item will be wrapped in a span.active for additional styling `Books` has a Level of `1`

> `Books` has a Level of `1` not `0` !

If you have multiple navigation on your site you can set different states for each one:

```
Nav::menu('main')->setCurrent(1)->setMaxLevel(1);
Nav::menu('sub')->setCurrent(2);

//will render until level == 1 from id 1 down
Nav::menu('main')->render();
// will render from id 2 down until the end
Nav::menu('sub')->render();
```

For the breadcrumbs you just call the same bucket:

```
//with Laravel
Nav::breadcrumbs()->render();

//without Laravel
$nav->breadcrumbs()->render();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

4391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17ddba213f51d47d59b3194ed526c9a49372a8f8133731795caa39ad950853ca?d=identicon)[bastiankoetsier](/maintainers/bastiankoetsier)

---

Top Contributors

[![bastiankoetsier](https://avatars.githubusercontent.com/u/6351038?v=4)](https://github.com/bastiankoetsier "bastiankoetsier (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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