PHPackages                             popphp/pop-nav - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. popphp/pop-nav

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

popphp/pop-nav
==============

Pop Nav Component for Pop PHP Framework

4.1.5(6mo ago)56.5k↓50%1BSD-3-ClausePHPPHP &gt;=8.3.0CI passing

Since Jul 21Pushed 6mo ago1 watchersCompare

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

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

pop-nav
=======

[](#pop-nav)

[![Build Status](https://github.com/popphp/pop-nav/workflows/phpunit/badge.svg)](https://github.com/popphp/pop-nav/actions)[![Coverage Status](https://camo.githubusercontent.com/50f76f20b37ed753a642cde4a85098b461971df57152e7e12a362cfb78e3e65a/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d6e6176)](http://cc.popphp.org/pop-nav/)

[![Join the chat at https://discord.gg/TZjgT74U7E](https://camo.githubusercontent.com/acad7b0eeb78b78d08ffd2b85681ab243436388b5f86f8bcb956a69246e53739/68747470733a2f2f6d656469612e706f707068702e6f72672f696d672f646973636f72642e737667)](https://discord.gg/TZjgT74U7E)

- [Overview](#overview)
- [Install](#install)
- [Quickstart](#quickstart)
- [Config](#config)
- [Using ACL](#using-acl)

Overview
--------

[](#overview)

`pop-nav` is a component for managing and rendering an HTML navigation tree. It includes support for injecting ACL functionality to display only the certain branches of the navigation tree that the current user role is allowed to access. For that, the `pop-acl` component is used.

`pop-nav` is a component of the [Pop PHP Framework](https://www.popphp.org/).

[Top](#pop-nav)

Install
-------

[](#install)

Install `pop-nav` using Composer.

```
composer require popphp/pop-nav

```

Or, require it in your composer.json file

```
"require": {
    "popphp/pop-nav" : "^4.1.5"
}

```

[Top](#pop-nav)

Quickstart
----------

[](#quickstart)

First, you can define the navigation tree:

```
$tree = [
    [
        'name'     => 'Users',
        'href'     => '/users',
        'children' => [
            [
                'name' => 'Roles',
                'href' => 'roles'
            ],
            [
                'name' => 'Config',
                'href' => 'config'
            ]
        ]
    ],
    [
        'name' => 'Orders',
        'href' => '/orders'
    ]
];
```

Then you can pass that to the nav object and render the nav:

```
$nav = new Nav($tree);
echo $nav;
```

```

        Users

                Roles

                Config

        Orders

```

[Top](#pop-nav)

Config
------

[](#config)

You have a significant amount of control over the branch nodes and attributes via a configuration array:

```
$config = [
    'top' => [
        'node'  => 'nav',
        'id'    => 'main-nav'
    ],
    'parent' => [
        'node'  => 'nav',
        'id'    => 'nav',
        'class' => 'level'
    ],
    'child' => [
        'node'  => 'nav',
        'id'    => 'menu',
        'class' => 'item'
    ],
    'on'  => 'link-on',
    'off' => 'link-off',
    'indent' => '    '
];
```

Using the same navigation tree from above, you can then create and render your nav object with the config:

```
use Pop\Nav\Nav;

$nav = new Nav($tree, $config);
echo $nav;
```

```

        Users

                Roles

                Config

        Orders

```

[Top](#pop-nav)

Using ACL
---------

[](#using-acl)

First, let's set up the ACL object with some roles and resources:

```
use Pop\Acl\Acl;
use Pop\Acl\AclRole as Role;
use Pop\Acl\AclResource as Resource;

$acl = new Acl();

$admin  = new Role('admin');
$editor = new Role('editor');

$acl->addRoles([$admin, $editor]);

$acl->addResource(new Resource('config'));
$acl->allow('admin');
$acl->deny('editor', 'config');
```

And then we add the ACL rules to the navigation tree:

```
$tree = [
    [
        'name'     => 'Home',
        'href'     => '/home',
        'children' => [
            [
                'name' => 'Users',
                'href' => 'users'
            ],
            [
                'name' => 'Config',
                'href' => 'config',
                'acl'  => [
                    'resource' => 'config'
                ]
            ]
        ]
    ],
    [
        'name' => 'Orders',
        'href' => '/orders'
    ]
];
```

We then inject the ACL object into the navigation object, set the current role and render the navigation:

```
$nav = new Nav($tree);
$nav->setAcl($acl);
$nav->setRole($editor);
echo $nav;
```

```

        Home

                Users

        Orders

```

Because the 'editor' role is denied access to the `config` page, that nav branch is not rendered. However, if the role is set to `$admin`, the `config` branch renders:

```
$nav = new Nav($tree);
$nav->setAcl($acl);
$nav->setRole($admin);
echo $nav;
```

```

        Home

                Users

                Config

        Orders

```

[Top](#pop-nav)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance66

Regular maintenance activity

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 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 ~187 days

Recently: every ~148 days

Total

21

Last Release

200d ago

Major Versions

2.1.0 → 3.0.02017-10-03

v2.x-dev → 3.2.02019-01-10

3.3.1 → 4.0.02023-12-18

PHP version history (8 changes)2.0.0PHP &gt;=5.4.0

3.0.0PHP &gt;=5.6.0

3.2.0PHP &gt;=7.1.0

3.3.0PHP &gt;=7.3.0

3.3.1PHP &gt;=7.4.0

4.0.0PHP &gt;=8.1.0

4.1.3PHP &gt;=8.2.0

4.1.5PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c19dee900e9e20039c723cc403f76b5c22ac2dddb3f86773ae64fb082d4949e2?d=identicon)[nicksagona](/maintainers/nicksagona)

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (52 commits)")

---

Tags

phphtmlaclnavigationnavpoppop php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/popphp-pop-nav/health.svg)

```
[![Health](https://phpackages.com/badges/popphp-pop-nav/health.svg)](https://phpackages.com/packages/popphp-pop-nav)
```

###  Alternatives

[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[shanmuga/laravel-entrust

This package provides a flexible solution to add ACL to Laravel

68312.9k2](/packages/shanmuga-laravel-entrust)[popphp/pop-form

Pop Form Component for Pop PHP Framework

1317.7k2](/packages/popphp-pop-form)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[popphp/popphp-framework

The Pop PHP Framework - Full Installation

686.5k1](/packages/popphp-popphp-framework)[popphp/pop-pdf

PHP PDF library for generating and importing PDF documents. A component of the Pop PHP Framework

207.8k1](/packages/popphp-pop-pdf)

PHPackages © 2026

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