PHPackages                             laravelista/ekko - 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. laravelista/ekko

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

laravelista/ekko
================

Framework agnostic PHP package for marking navigation items active.

4.1.1(5y ago)274700.4k↓34.9%284MITPHPPHP ^8.0CI failing

Since May 22Pushed 5y ago11 watchersCompare

[ Source](https://github.com/laravelista/Ekko)[ Packagist](https://packagist.org/packages/laravelista/ekko)[ Patreon](https://www.patreon.com/laravelista)[ RSS](/packages/laravelista-ekko/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (6)Versions (26)Used By (4)

Ekko
====

[](#ekko)

Framework agnostic PHP package for marking navigation items active.

[![Become a Patron](https://camo.githubusercontent.com/16fde1abb7601eba23de38f592bc54e3a7d10da24ac58db594d7fab32d449d46/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4265636f6d65253230612d506174726f6e2d6639363835342e7376673f7374796c653d666f722d7468652d6261646765)](https://www.patreon.com/laravelista)

Features
--------

[](#features)

- Framework agnostic.
- Can be modified for any custom application and UI.
- Currently supported frameworks: Laravel (PRs are welcome!).
- Global helper functions disabled by default.
- Supports default output value.
- Backward compatible.
- Fully tested using table driven testing (data providers in PHPUnit).

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

[](#installation)

From the command line:

```
composer require laravelista/ekko
```

By default Ekko is initialized with these sensible defaults:

- the default output value is `active`.
- it uses GenericUrlProvider (`$_SERVER['REQUEST_URI']`).
- global helper functions are disabled.

### Laravel

[](#laravel)

The only dependency for this package is PHP ^8.0, meaning that you can possibly install it on any Laravel version that supports PHP 8 (I think that for now this is only Laravel 8). The service provider is always going to follow the latest Laravel release and try to be as backward compatible as possible.

Laravel 8 will use the auto-discovery function to register the ServiceProvider and the Facade.

If you are not using auto-discovery, you will need to include the service provider and facade in `config/app.php`:

```
'providers' => [
    ...,
    Laravelista\Ekko\Frameworks\Laravel\ServiceProvider::class
];

```

And add a facade alias to the same file at the bottom:

```
'aliases' => [
    ...,
    'Ekko' => Laravelista\Ekko\Frameworks\Laravel\Facade::class
];

```

Overview
--------

[](#overview)

To mark a menu item active in [Bootstrap](http://getbootstrap.com/components/#navbar), you need to add a `active` CSS class to the `` tag:

```

    Home
    About

```

You could do it manually with Laravel, but you will end up with a sausage:

```

    Home
    About

```

With Ekko your code could look like this:

```

    Home
    About

```

or like this:

```

    Home
    About

```

or this:

```

    Home
    About

```

### Default output value

[](#default-output-value)

What if you are not using Bootstrap, but some other framework or a custom design? Instead of returning `active` CSS class, you can make Ekko return anything you want.

```

    Home
    About

```

You can alse set the **default output value** if you don't want to type it everytime:

```
$ekko = new Ekko;
$ekko->setDefaultValue('highlight');
return $ekko->isActive('/');
```

or in Laravel you can set the default output value in the config `config/ekko.php` file:

```
