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

ActiveLibrary[Framework](/categories/framework)

depa/middleware-navigation
==========================

The middleware navigation is a PSR-15 middleware that provides navigation functionality to a Zend Expressive application

v0.2.7.2(6y ago)0461MITPHP

Since May 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/depa-berlin/Middleware-Navigation)[ Packagist](https://packagist.org/packages/depa/middleware-navigation)[ Docs](https://github.com/depa-berlin/Middleware-Navigation)[ RSS](/packages/depa-middleware-navigation/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (17)Used By (0)

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

[](#middleware-navigation)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![StyleCI](https://camo.githubusercontent.com/09fd89d8e39fb4c11b1177264f5a1b6168132da55c7ed3babc1e9afe1d6b0602/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138333931343130302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/183914100)[![Coverage Status](https://camo.githubusercontent.com/cbce634704fcb2dafa19be7f85d8fb2081e5a96d8d6b8a7f56c4279717f650a7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f646570612d6265726c696e2f4d6964646c65776172652d4e617669676174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/depa-berlin/Middleware-Navigation?branch=master)

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

[](#installation)

Run the following to install this library:

```
$ composer require depa/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(depa\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' => [...], //possibilitys in attributes-table described (at the bottom of the doc)
]
```

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

```
'{navigation_Name}' => [
    'linkAttributes' => [...], //possibilitys 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.designpark.de}',
]
```

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

```
'{navigation_Name}' => [
    'route' => '{route_name}',
    'uri' => '{https://www.designpark.de}',
    'attributes' => [
        'id' => '{some_id}',
        'class' => ['{class1} {class2}'],
    ],
    'linkAttributes' => [
        'id' => '{some_id}',
        'class' => '{class_1} {class2}',
    ],
    'childs' => [
        '{childNavigation_Name}' => [
            'route' => '{route_name}',
            'uri' => '{https://www.designpark.de}',
            'attributes' => [],
            'linkAttributes' => [],
            'childs' => [],
        ]
    ]
]
```

The example provided above would output the following HTML:

```
