PHPackages                             marcel-maqsood/middleware-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. [Framework](/categories/framework)
4. /
5. marcel-maqsood/middleware-navigation

ActiveLibrary[Framework](/categories/framework)

marcel-maqsood/middleware-navigation
====================================

The middleware navigation is a PSR-15 middleware that provides navigation functionality to a Laminas Mezzio application

v0.2.8.4(1y ago)072MITPHP

Since May 7Pushed 1y agoCompare

[ Source](https://github.com/marcel-maqsood/Middleware-Navigation)[ Packagist](https://packagist.org/packages/marcel-maqsood/middleware-navigation)[ Docs](https://technikhafen.de)[ RSS](/packages/marcel-maqsood-middleware-navigation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (0)

Middleware-Navigation
=====================

[](#middleware-navigation)

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

[](#installation)

Run the following to install this library:

```
$ composer require marcel-maqsood/middleware-navigation
```

Documentation
-------------

[](#documentation)

After installing the module, you have to implement the navigation-middleware into your pipeline, so you basically add this line above the RouteMiddleware:

```
     $app->pipe(MazeDEV\NavigationMiddleware\Middleware\NavigationMiddleware::class);
```

To create a navigation, use the navigation.global.php (it's inside the config folder) as your basic (put it into config\\autoload)

The basic structure of a menu-item must look like this:

```
'{navigation_Name}' => [
    'route' => '{route_name}', //route-name which is set in routes.php
]
```

if you want to add attributes to a menu-item (to the ul element), do this:

```
'{navigation_Name}' => [
    'attributes' => [...], //possibilities in attributes-table described (at the bottom of the doc)
]
```

You could also add a nice little icon infront of your List Item by configuring it like that:

```
'{navigation_Name}' => [
    'display' => 'fas fa-home nav-icon' // Would display a home icon infront of your link
]
```

if you want to add link-attributes to a menu-item (to the a element), do this:

```
'{navigation_Name}' => [
    'linkAttributes' => [...], //possibilities in link-attributes-table described (at the bottom of the doc)
]
```

if you want to add child-items to a menu-item, do this (you can use as many as you want):

```
'{navigation_Name}' => [
    'childs' => [...], //build the same as a normal menu-item
]
```

if you want to force a link-direction to an item then add this:

```
'{navigation_Name}' => [
    'uri' => '{https://www.technikhafen.de}',
]
```

A menu-item which contains any of the given examples could look like this:

```
'{navigation_Name}' => [
    'display' => 'fas fa-home nav-icon'
    'route' => '{route_name}',
    'permission' => 'somePermission',
    'uri' => '{https://www.technikhafen.de}',
    'attributes' => [
        'id' => '{some_id}',
        'class' => ['{class1} {class2}'],
    ],
    'linkAttributes' => [
        'id' => '{some_id}',
        'class' => '{class_1} {class2}',
    ],
    'childs' => [
        '{childNavigation_Name}' => [
            'display' => 'fas fa-home nav-icon'
            'route' => '{route_name}',
            'permission' => 'somePermission2',
            'uri' => '{https://www.technikhafen.de}',
            'attributes' => [],
            'linkAttributes' => [],
            'childs' => [],
        ]
    ]
]
```

The example provided above would output the following HTML:

```
