PHPackages                             mjanssen/laravel-5-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. mjanssen/laravel-5-breadcrumbs

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

mjanssen/laravel-5-breadcrumbs
==============================

A simple and powerfull way to create breadcrumbs in Laravel 5+

1545.7k↓33.3%7[3 issues](https://github.com/mjanssen/Laravel-5-breadcrumbs-bundle/issues)[2 PRs](https://github.com/mjanssen/Laravel-5-breadcrumbs-bundle/pulls)PHP

Since Oct 12Pushed 8y ago4 watchersCompare

[ Source](https://github.com/mjanssen/Laravel-5-breadcrumbs-bundle)[ Packagist](https://packagist.org/packages/mjanssen/laravel-5-breadcrumbs)[ RSS](/packages/mjanssen-laravel-5-breadcrumbs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel-5-breadcrumbs-bundle
============================

[](#laravel-5-breadcrumbs-bundle)

A simple solution for breadcrumbs in Laravel 5+

Edit the .json
==============

[](#edit-the-json)

Edit your .json file and add the following line to your "require"

`"mjanssen/laravel-5-breadcrumbs": "dev-master"`

After this run the `composer update` to update your framework and get the breadcrumb class loaded into your files. The files will be placed in the `vendor/mjanssen/laravel-5-breadcrumbs` folder.

The class can now be used within the framework. Make sure you **use** it in *controllers* for example.

`use mjanssen\BreadcrumbsBundle\Breadcrumbs;`

Usage
=====

[](#usage)

As my first breadcrumb bundle () needed some attention (automatic generating, updated config file etc...). This breadcrumb bundle is optimized for Laravel 5.

At first, the Breadcrumbs will be empty. To add breadcrumbs, use the *addBreadcrumb()* function

```
// Three breadcrumbs will be stored
Breadcrumbs::addBreadcrumb('Home', '/');
Breadcrumbs::addBreadcrumb('Second crumb', '/second-page');
Breadcrumbs::addBreadcrumb('Third crumb', '/second-page/third-page');

```

To generate the breadcrumb HTML, you can use the *generate()* function.

```
// Will return the html for the three previous set breadcrumbs.
Breadcrumbs::generate();

```

"Undefined index ..."
---------------------

[](#undefined-index-)

If you are receiving an error about "undefined index ...", please make sure you copied the config file to your /config directory (under /config/breadcrumbs.php).

Additional methods
------------------

[](#additional-methods)

### Automatic generation

[](#automatic-generation)

For an easy way of generating breadcrumbs, the bundle also provides an *automatic()* function. This function will retreive the segments from the current url, and builds the breadcrumbs around them. *Breadcrumb::generate()* is not needed, since the *automatic()* function will build the breadcrumbs, and returns the HTML for the breadcrumbs.

`Breadcrumbs::automatic();`

### Removing stored breadcrumbs

[](#removing-stored-breadcrumbs)

To remove all the breadcrumbs you set, simply use `Breadcrumbs::truncate();` to remove all the stored breadcrumbs.

### Retrieving the stored breadcrumbs

[](#retrieving-the-stored-breadcrumbs)

To get the stored breadcrumbs in a structured array, call `Breadcrumbs::getBreadcrumbs();`. This will return an array which contains the information used to create the breadcrumbs.

Example global usage
--------------------

[](#example-global-usage)

If you are interested to make use of the breadcrumbs globally, you can use the view composer function to make this happen.

Create a view called `breadcrumbs.blade.php`

Inside the `AppServiceProvider` create a function called *composer()*, and call it from the already existing *boot()* function. Inside the *composer()* function you can set composers for views. We will compose the breadcrumbs view.

```
View::composer('components.breadcrumbs', function() {

	$data = [
		'global_breadcrumbs' => Breadcrumbs::automatic()
	];

	view()->share($data);
});

```

Inside the `breadcrumbs.blade.php` file, you are now able to use the `{!! $global_breadcrumbs !!}` var. Include the view from a `master.blade.php` file (or whatever your layout file is called). This can be done with `@include`

`@include(components/breadcrumbs) // Assuming you placed the breadcrumbs.blade.php file in a components folder`

The breadcrumbs will now show up on every page where your layout is used.

#### Changing the base url (for automatic breadcrumbs)

[](#changing-the-base-url-for-automatic-breadcrumbs)

To make the home segment in the automatic breadcrumbs link to an other page

`first segment -> Home (example.com)` => `first segment -> Home (example.com/admin)`

You can change the base url with `Breadcrumbs::setHomeUrlBase("admin")` (for this example). Please note, this function only works for the automatic breadcrumb generation, since the addBreadcrumb method already expects full url's.

Options
=======

[](#options)

```
uppercaseFirst
useSeparator
bootstrapSeparator
separator
lastBreadcrumbClickable
automaticFirstCrumb
ulLiClass
bootstrap
except
stripHtmlExtension

```

Additionally you can use a config file to edit some features, for example the separator. To do this, create a php file in the `/config` folder called: `breadcrumbs.php`. The source files of this Repo, there will be an example config file which includes all the available options + information about them.

To remove id's (used for products or persons e.d.), put "numbers\*" in the except array. This way numbers are removed from the breadcrumbs.

Config file can be found at: [https://github.com/mjanssen/Laravel-5-breadcrumbs-bundle/blob/master/config\_file\_breadcrumbs.php](https://github.com/mjanssen/Laravel-5-breadcrumbs-bundle/blob/master/config_file_breadcrumbs.php)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.5% 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.

### Community

Maintainers

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

---

Top Contributors

[![mjanssen](https://avatars.githubusercontent.com/u/1145427?v=4)](https://github.com/mjanssen "mjanssen (23 commits)")[![niknetniko](https://avatars.githubusercontent.com/u/1756811?v=4)](https://github.com/niknetniko "niknetniko (2 commits)")[![drmonkeyninja](https://avatars.githubusercontent.com/u/357623?v=4)](https://github.com/drmonkeyninja "drmonkeyninja (1 commits)")

### Embed Badge

![Health badge](/badges/mjanssen-laravel-5-breadcrumbs/health.svg)

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

###  Alternatives

[freshbitsweb/laravel-cart-manager

Managing the cart of your Laravel application is a breeze

22622.3k1](/packages/freshbitsweb-laravel-cart-manager)

PHPackages © 2026

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