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

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

stephanecoinon/navigation
=========================

Simple static navigation handler

v0.1(11y ago)013PHPPHP &gt;=5.4.0

Since Jul 8Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

Navigation [![Build Status](https://camo.githubusercontent.com/0c6381f947716a90e934b46070697141433a518f7d28f61455594dd71f4834b8/68747470733a2f2f7472617669732d63692e6f72672f7374657068616e65636f696e6f6e2f6e617669676174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stephanecoinon/navigation)
=====================================================================================================================================================================================================================================================================================================================

[](#navigation-)

Simple handler for navigation configuration.

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

[](#installation)

In your terminal, just run:

```
composer require "stephanecoinon/navigation":"dev-master"
```

Usage
-----

[](#usage)

### Create a single navigation

[](#create-a-single-navigation)

```
// Add this code in your controller

use Coinon\Navigation\Navigation;

// Describe the navigation items
// Ideally, you should load this from a configuration file
// Each item can define the following keys:
//   title:  (mandatory) title to display on the link
//   slug:   (optional)  if omitted, the package will slugify the title
//   active: (optional)  flag to say whether the item is the
//                       currently active one, true by default
//   url:    (optional)  absolute URL or URL relative to the
//                       base URL passed to constructor.
//                       Using the slug by default
//
$navConfiguration = [
    ['title' => 'Home'],
    ['title' => 'About us'],
    [
        'title' => 'Contact us',
        'slug'  => 'contact',  // will be used for URL in this case
    ],
];

// The base URL in second argument is optional
$navigation = new Navigation($navConfiguration, 'http://app.dev:8000');
// Flag the active item by slug
$navigation->activateItem('about-us');

// then pass $navigations to your views

// Add this code in your view

  >
