PHPackages                             theorythree/navprompt - 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. theorythree/navprompt

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

theorythree/navprompt
=====================

An easy-to-use navigation helper for your Laravel projects.

v1.1.0(8y ago)064MITPHPPHP ~5.6|~7.0

Since Jan 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/theorythree/NavPrompt)[ Packagist](https://packagist.org/packages/theorythree/navprompt)[ Docs](https://github.com/TheoryThree/NavPrompt)[ RSS](/packages/theorythree-navprompt/feed)WikiDiscussions master Synced 3d ago

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

NavPrompt
=========

[](#navprompt)

[![Latest Version on Packagist](https://camo.githubusercontent.com/055979ad8a5a480c4083c37f59ba2d0b46dbc6a55b7b91f197f4ff13947d91f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468656f727974687265652f4e617650726f6d70742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/theorythree/NavPrompt)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/d24cef5d2b4520d39697c518a23832ea5d74a73f54dd2d720f087878db514abc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468656f727974687265652f4e617650726f6d70742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/theorythree/NavPrompt)[![Total Downloads](https://camo.githubusercontent.com/b2dbfc716a2d2e89d82908fc2fe1c2332ab617e73224bcf3cd1868287b72f874/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468656f727974687265652f4e617650726f6d70742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/theorythree/NavPrompt)

Description
-----------

[](#description)

> A simple solution for a simple problem. This package marks HTML elements with a CSS `is-active` class based on the current URI. Although this package was originally conceived to be used on navigation, it can be used anywhere you need to mark elements with an active class name.

How to Install
--------------

[](#how-to-install)

### Step 1: Via Composer

[](#step-1-via-composer)

```
$ composer require theorythree/navprompt
```

### Step 2: Define the service provider and alias in your Laravel project

[](#step-2-define-the-service-provider-and-alias-in-your-laravel-project)

This package takes advantage of the new *auto-discovery* feature found in Laravel 5.5+. If you're using that version of Laravel, then you may skip this step.

Add NavPrompt Service Provider to `config/app.php`.

```
'providers' => [

  /*
   * Application Service Providers...
   */

  TheoryThree\NavPrompt\NavPromptServiceProvider::class,
];
```

Define the NavPrompt Alias to `config/app.php`.

```
'aliases' => [

  /*
   * Aliases
   */
  'Nav' => TheoryThree\NavPrompt\NavPromptFacade::class,
];
```

### Step 3. Publish the plugin config file (Optional)

[](#step-3-publish-the-plugin-config-file-optional)

Publish the configuration file to override the package defaults. The package is setup by default to work with [Bulma](https://bulma.io) - which uses an active class name of `is-active`, however if your project is using **Bootstrap**, you'll want to override the default active class name to `active`. To do this, publish the config file used by this plugin and set the override for the `active_class` value to `active`.

`$ php artisan vendor:publish --tag=navprompt`This command will generate a config file in `config/navprompt.php`.

```
return [

    'active_class' => 'is-active',  // change to 'active' for Bootstrap
];
```

### Usage

[](#usage)

This package uses the alias `Nav::` to access the plugin class in your project template files. You can use any of the following methods to check your routes against:

1. routeIsNamed() // checks URI against Laravel named route
2. routeIs() // checks URI against full URI provided
3. routeContains() // checks URI to see if it contains provided slug

---

### routeIsNamed()

[](#routeisnamed)

`String routeIsNamed( String $route, String $active=NULL )`

#### Description

[](#description-1)

> Accepts a string of the desired Laravel named route for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match).

#### Parameters

[](#parameters)

###### $route

[](#route)

String: The Laravel route name to test against

###### $active

[](#active)

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

#### Example

[](#example)

```
// Route 1: Route::get('/about', 'AboutController@index')->name('about');
// Current URL: http://www.mycompany.com/about

About Us
// returns 'is-active' string

// result:
About Us
```

---

### routeIs()

[](#routeis)

`String routeIs( String $route, String $active=NULL )`

#### Description

[](#description-2)

> This method is designed to be used in cases when testing the full URI path is needed. For example, if you have several, similar links that you need to test.

> Accepts a string of the full URI for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match). This method is designed to be used in cases where

#### Parameters

[](#parameters-1)

###### $route

[](#route-1)

String: The full URI route to test against

###### $active

[](#active-1)

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

#### Example

[](#example-1)

```
// Current URL: http://www.mycompany.com/about/team/dan-merfeld/

About Dan
// returns 'is-active' string

// result:
About Dan
```

---

### routeContains()

[](#routecontains)

`String routeContains( String|Array $slugs, Int|Array $positions, String $active=NULL )`

#### Description

[](#description-3)

> This method is designed to be used in cases when you need to check for the existence of a specific URI slug within the full URI path.

> Accepts a string (or array of strings) of the URI slug(s), and an optional position integer (or array of integers), for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match). This method is designed to be used in cases where

#### Parameters

[](#parameters-2)

###### $slugs

[](#slugs)

String|Array: The URI slug(s) to test against

###### $positions

[](#positions)

Int | Array (OPTIONAL): The position(s) of the URI slug in relation to the full URI.

###### $active

[](#active-2)

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

#### Example

[](#example-2)

Basic Example:

```
// Current URL: http://www.mycompany.com/about/team/dan/

About Dan
// returns 'is-active' string

// result:
About Dan
```

Basic Position Example:

```
// Current URL: http://www.mycompany.com/about/team/dan/

// position 1 = "about"
// position 2 = "team"
// position 3 = "dan"

About Dan
// returns '' string

// result:
About Dan
```

Advanced Position Example:

```
// Current URL: http://www.mycompany.com/sports/contact/football/

// position 1 = "sports"
// position 2 = "contact"
// position 3 = "football"

Contact Us
// returns '' string
// Result: Contact Us

List all Contact Sports
// returns 'is_active' string
// Result: List all Contact Sports

List all Contact Sports
// returns 'is_active' string
// Result: List all Contact Sports
```

---

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

All contributors welcome. If you would like to contribute to this package please feel to submit a pull request, submit an issue, or request a feature.

See our [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for more details.

Credits
-------

[](#credits)

- [Dan Merfeld](https://github.com/dmerfeld) - Author and Maintainer.

Contact
-------

[](#contact)

Want to get in touch to discuss this package, or another one you'd like us to build? Feel free to reach out to the maintainer of this package by emailing me at , follow or @ me on Twitter [@dmerfeld](https://twitter.com/dmerfeld). I'd really like to hear from you. Honest.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~1 days

Total

3

Last Release

3047d ago

Major Versions

v0.1.0 → v1.0.02018-01-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/564f43b9955db71e7e6e573d7a65e53a6de9f604c6e440f163f8989ddd4dbd25?d=identicon)[dmerfeld](/maintainers/dmerfeld)

---

Top Contributors

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

---

Tags

TheoryThreeNavPrompt

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/theorythree-navprompt/health.svg)

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

###  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)[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)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)

PHPackages © 2026

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