PHPackages                             naucon/breadcrumbs - 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. naucon/breadcrumbs

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

naucon/breadcrumbs
==================

The breadcrumb package helps to integrate a common breadcrumb navigation into a web application. The package includes two components: A breadcrumbs class to add breadcrumb elements and a breadcrumbs helper to render html markup in php or smarty templates.

2.0.1(3mo ago)1225.4k↑10.5%5MITPHPPHP &gt;=7.2.0CI passing

Since Dec 13Pushed 3mo ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (6)Used By (0)

naucon Breadcrumbs Package
==========================

[](#naucon-breadcrumbs-package)

About
-----

[](#about)

The breadcrumb package helps to integrate a common breadcrumb navigation into a web application. The package includes two components: A breadcrumbs class to add breadcrumb elements and a breadcrumbs helper to render html markup in php or smarty templates.

### Features

[](#features)

- add breadcrumbs with a title and a optional URL
- breadcrumb handler (null - default, session)
- breadcrumb helper to render html markup
- smarty plugins for breadcrumb helper
- reverse breadcrumb (fifo, lifo)
- fluent interface \*\* Breadcrumbs (add) \*\* BreadcrumbsHelper (setTag, setSeparator, setReverse, setOptions)

### Compatibility

[](#compatibility)

- PHP7.2+

### Dependencies

[](#dependencies)

- naucon Utility
- naucon Html Elements

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

[](#installation)

install the latest version via composer

```
composer require naucon/breadcrumbs

```

Usage
-----

[](#usage)

### initialize

[](#initialize)

To build a breadcrumb menu create a instance of `Breadcrumbs`.

```
use Naucon\Breadcrumbs\Breadcrumbs;
$breadcrumbs = new Breadcrumbs();

```

Afterwards you can add breadcrumbs to that instance with the method `add()`. This the first parameter a title of the breadcrumb must be defined. With the second parameter a URL can be defined (optional).

```
$breadcrumbs->add('home', '/home/');
$breadcrumbs->add('profile', '/profile/');
$breadcrumbs->add('address');

```

Another way is with the fluent interface.

```
$breadcrumbs->add('home', '/home/');
    ->add('profile', '/profile/');
    ->add('address');

```

With `foreach` you can iterate through the added breadcrumbs. The value is a instance of `Breadcrumb` which have methodes to access breadcrumb title and URL. The breadcrumbs a in the order they are added (FIFO).

```
foreach ($breadcrumbs as $breadcrumb)
{
    if ($breadcrumb->hasUrl()) {
        echo '' . $breadcrumb->getTitle() . '';
    } else {
        echo $breadcrumb->getTitle();
    }
}

```

The output of the example would be

```
homeprofileaddress

```

To reverse the order of the breadcrumb use the method `getReverseIterator()`. The breadcrumbs will be interated in the reverse order they are added (LIFO).

```
$breadcrumbsIterator = $breadcrumbs->getReverseIterator();
foreach ($breadcrumbsIterator as $breadcrumb)
{
    if ($breadcrumb->hasUrl()) {
        echo '' . $breadcrumb->getTitle() . '';
    } else {
        echo $breadcrumb->getTitle();
    }
}

```

The output of the example would be

```
addressprofilehome

```

### Breadcrumb Handler

[](#breadcrumb-handler)

Breadcrumb items are collected in a instance of `BreadcrumbCollection`. To read and write into the collection a handler is used. The default handler is `BreadcrumbHandlerNull` which only adds or remove entries to the collection.

In some use cases the breadcrumb entries must persist between page loads. In this cases the `BreadcrumbHandlerSession` can be set. The Handler will read and write into the $\_SESSION variable.

```
// start session
session_start();

...

use Naucon\Breadcrumbs\Breadcrumbs;
use Naucon\Breadcrumbs\Handler\BreadcrumbHandlerSession;
$breadcrumbs = new Breadcrumbs();
$breadcrumbs->setBreadcrumbHandler(new BreadcrumbHandlerSession());

...

// add breadcrumb entry
$breadcrumbs->add('Home', '/home/');

...

// close session
session_write_close();

```

Make sure that you started and close session befor and after you use the breadcrumb.

### Breadcrumb helper

[](#breadcrumb-helper)

With the breadcrumb helper a instance of `Breadcrumbs` can be rendered in HTML Markup.

To use the helper create a instance of `BreadcrumbsHelper` and give the constructor a instance of `Breadcrumbs`.

```
use Naucon\Breadcrumbs\Helper\BreadcrumbsHelper;
$breadcrumbsHelper = new BreadcrumbsHelper($breadcrumbs);

```

With the method `render()` the html markup will be generated an returned.

```
echo $breadcrumbsHelper->render();

// homeprofileaddress

```

With the method `setSeparator()` a separator between the breadcrumbs can be defined.

```
$breadcrumbsHelper->setSeparator(' / ');
echo $breadcrumbsHelper->render();

// home / profile / address

```

With the method `setReverse()` the order of the breadcrumbs can be reversed.

```
$breadcrumbsHelper->setReversed(); // or $breadcrumbsHelper->setReversed(true);
echo $breadcrumbsHelper->render();

// address / profile / home

```

With the method `setSkipLinks()` links will be skipped in render.

```
$breadcrumbsHelper->setSkipLinks(); // or $breadcrumbsHelper->setSkipLinks(true);
echo $breadcrumbsHelper->render();

// home / profile / home

```

With the method `setTag()` a html element can be set surround the breadcrumb. The following html element are supported: span, div, li, ul, ol

Example with `span` element:

```
$breadcrumbsHelper->setTag('span');
$breadcrumbsHelper->setSeparator(' / ');
echo $breadcrumbsHelper->render();

// home / profile / address

```

Example with `div` element:

```
$breadcrumbsHelper->setTag('div');
$breadcrumbsHelper->setSeparator(' / ');
echo $breadcrumbsHelper->render();

// home / profile / address

```

Example with `li` element:

```
$breadcrumbsHelper->setTag('div');
$breadcrumbsHelper->setSeparator(' / ');
echo $breadcrumbsHelper->render();

// home / profile / address

```

When using the tag `ul` or `ol` also the attributes `id`, `class`, `style` can be defined.

Example with `ul` element:

```
$breadcrumbsHelper->setTag('ul');
$breadcrumbsHelper->setOptions(array('id' => 'breadcrumb', 'class' => 'breadcrumbs'));
echo $breadcrumbsHelper->render();

// homeprofileaddress

```

Example with `ol` element:

```
$breadcrumbsHelper->setTag('ol');
$breadcrumbsHelper->setOptions(array('id' => 'breadcrumb', 'class' => 'breadcrumbs'));
echo $breadcrumbsHelper->render();

// homeprofileaddress

```

### Breadcrumb Smarty Plugin

[](#breadcrumb-smarty-plugin)

When using the Smarty Template Engine the breadcrumb helper can be integrated with a smarty plugin.

First have hook up the smarty plugins to smarty.

```
$smartyObject->plugins_dir[] = PATH_LIBRARY . 'vendor/naucon/Breadcrumbs/SmartyPlugins';

```

Next assign the instance of `Breadcrumbs` class to smarty.

```
$smarty->assign('breadcrumbs', $breadcrumbs);

```

Then add the plugin to the template.

```
{ncbreadcrumbs from=$breadcrumbs tag='span' separator=' / '}

```

or

```
{ncbreadcrumbs from=$breadcrumbs tag='div' separator=' / '}

```

or

```
{ncbreadcrumbs from=$breadcrumbs tag='ul' id='breadcrumb' class='breadcrumbs'}

```

or

```
{ncbreadcrumbs from=$breadcrumbs tag='ol' id='breadcrumb' class='breadcrumbs'}

```

or

```
{ncbreadcrumbs from=$breadcrumbs tag='ol' id='breadcrumb' class='breadcrumbs' reverse=true}

```

or

```
{ncbreadcrumbs from=$breadcrumbs separator=' / ' skip-links=true}

```

The smarty plugin supports the following parameters

- from = assigned breadcrumbs variable (MUST)
- tag = define html tag surrounding the breadcrumb elements (optional)
- separator = define separator between the breadcrumb elements (optional)
- reverse = define the order that the breadcrumbs is iterated (optional)
- skip-links = links will not be rendered (optional)
- id = define a id attribute on a surrounding html element like ul and ol but not div, span or li (optional)
- class = define a id attribute on a surrounding html element like ul and ol but not div, span or li (optional)
- style = define a id attribute on a surrounding html element like ul and ol but not div, span or li (optional)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance82

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% 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 ~928 days

Total

5

Last Release

97d ago

Major Versions

1.0.2 → 2.0.02025-04-28

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP &gt;=7.2.0

### Community

Maintainers

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

---

Top Contributors

[![naucon](https://avatars.githubusercontent.com/u/1407477?v=4)](https://github.com/naucon "naucon (10 commits)")[![ahaskioglu-valiton](https://avatars.githubusercontent.com/u/129849892?v=4)](https://github.com/ahaskioglu-valiton "ahaskioglu-valiton (3 commits)")

---

Tags

navigationbreadcrumbsbreadcrumb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/naucon-breadcrumbs/health.svg)

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

###  Alternatives

[spatie/menu

Html menu generator

7592.9M6](/packages/spatie-menu)[slope-it/breadcrumb-bundle

A bundle for generating dynamic breadcrumbs in Symfony applications

1865.5k](/packages/slope-it-breadcrumb-bundle)[extpoint/yii2-megamenu

Configurable site map with auto generate page title, breadcrumbs and navigation

3310.9k](/packages/extpoint-yii2-megamenu)[geeklabs/ci4-breadcrumbs

Breadcrumb navigation for CodeIgniter 4

2813.5k](/packages/geeklabs-ci4-breadcrumbs)

PHPackages © 2026

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