A simple Laravel-style way to create breadcrumbs.
- Compatibility Chart
- Getting Started
- Defining Breadcrumbs
- Custom Templates
- Outputting Breadcrumbs
- Structured Data
- Route-Bound Breadcrumbs
- Advanced Usage
- API Reference
- Changelog
- Technical Support
- Bug Reports
- Contributing
- License
Laravel Breadcrumbs | Laravel | PHP |
---|---|---|
4.x | 5.5 | 7.0+ |
3.x | 5.0 – 5.4 | 5.4+ |
2.x | 4.0 – 4.2 | 5.3+ |
Run this at the command line:
composer require davejamesmiller/laravel-breadcrumbs:4.x
This will both update composer.json
and install the package into the vendor/
directory.
Create a file called routes/breadcrumbs.php
that looks like this:
<?php
// Home
Breadcrumbs::register('home', function ($breadcrumbs) {
$breadcrumbs->push('Home', route('home'));
});
// Home > About
Breadcrumbs::register('about', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('About', route('about'));
});
// Home > Blog
Breadcrumbs::register('blog', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('Blog', route('blog'));
});
// Home > Blog > [Category]
Breadcrumbs::register('category', function ($breadcrumbs, $category) {
$breadcrumbs->parent('blog');
$breadcrumbs->push($category->title, route('category', $category->id));
});
// Home > Blog > [Category] > [Post]
Breadcrumbs::register('post', function ($breadcrumbs, $post) {
$breadcrumbs->parent('category', $post->category);
$breadcrumbs->push($post->title, route('post', $post));
});
See the Defining Breadcrumbs section for more details.
By default a Bootstrap-compatible ordered list will be rendered, so if you're using Bootstrap 4 you can skip this step.
First initialise the config file by running this command:
php artisan vendor:publish --provider="DaveJamesMiller\Breadcrumbs\BreadcrumbsServiceProvider"
Then open config/breadcrumbs.php
and edit this line:
'view' => 'breadcrumbs::bootstrap4',
The possible values are:
breadcrumbs::bootstrap4
– Bootstrap 4breadcrumbs::bootstrap3
– Bootstrap 3breadcrumbs::bootstrap2
– Bootstrap 2breadcrumbs::bulma
– Bulmabreadcrumbs::foundation6
– Foundation 6breadcrumbs::materialize
– Materializebreadcrumbs::json-ld
– JSON-LD Structured Data (<script> tag, no visible output)- The path to a custom view: e.g.
partials.breadcrumbs
See the Custom Templates section for more details.
Finally, call Breadcrumbs::render()
in the view template for each page, passing it the name of the breadcrumb to use and any additional parameters – for example:
{{ Breadcrumbs::render('home') }}
{{ Breadcrumbs::render('category', $category) }}
See the Outputting Breadcrumbs section for other output options, and see Route-Bound Breadcrumbs for a way to link breadcrumb names to route names automatically.
Breadcrumbs will usually correspond to actions or types of page. For each breadcrumb you specify a name, the breadcrumb title and the URL to link it to. Since these are likely to change dynamically, you do this in a closure, and you pass any variables you need into the closure.
The following examples should make it clear:
The most simple breadcrumb is probably going to be your homepage, which will look something like this:
Breadcrumbs::register('home', function ($breadcrumbs) {
$breadcrumbs->push('Home', route('home'));
});
As you can see, you simply call $breadcrumbs->push($title, $url)
inside the closure.
For generating the URL, you can use any of the standard Laravel URL-generation methods, including:
url('path/to/route')
(URL::to()
)secure_url('path/to/route')
route('routename')
orroute('routename', 'param')
orroute('routename', ['param1', 'param2'])
(URL::route()
)action('controller@action')
(URL::action()
)- Or just pass a string URL (
'http://www.example.com/'
)
This example would be rendered like this:
{{ Breadcrumbs::render('home') }}
And results in this output:
Home
This is another static page, but this has a parent link before it:
Breadcrumbs::register('blog', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('Blog', route('blog'));
});
It works by calling the closure for the home
breadcrumb defined above.
It would be rendered like this:
{{ Breadcrumbs::render('blog') }}
And results in this output:
Home / Blog
Note that the default template does not create a link for the last breadcrumb (the one for the current page), even when a URL is specified. You can override this by creating your own template – see Custom Templates for more details.
This is a dynamically generated page pulled from the database:
Breadcrumbs::register('post', function ($breadcrumbs, $post) {
$breadcrumbs->parent('blog');
$breadcrumbs->push($post->title, route('post', $post));
});
The $post
variable would simply be passed in from the view:
{{ Breadcrumbs::render('post', $post) }}
It results in this output:
Tip: You can pass multiple parameters if necessary.
Finally, if you have nested categories or other special requirements, you can call $breadcrumbs->push()
multiple times:
Breadcrumbs::register('category', function ($breadcrumbs, $category) {
$breadcrumbs->parent('blog');
foreach ($category->ancestors as $ancestor) {
$breadcrumbs->push($ancestor->title, route('category', $ancestor->id));
}
$breadcrumbs->push($category->title, route('category', $category->id));
});
Alternatively you could make a recursive function such as this:
Breadcrumbs::register('category', function ($breadcrumbs, $category) {
if ($category->parent) {
$breadcrumbs->parent('category', $category->parent);
} else {
$breadcrumbs->parent('blog');
}
$breadcrumbs->push($category->title, route('category', $category->slug));
});
Both would be rendered like this:
{{ Breadcrumbs::render('category', $category) }}
And result in this:
Home / Blog / Grandparent Category / Parent Category / Category Title
To customise the HTML, create your own view file (e.g. resources/views/partials/breadcrumbs.blade.php
) like this:
@if (count($breadcrumbs))
<ol class="breadcrumb">
@foreach ($breadcrumbs as $breadcrumb)
@if ($breadcrumb->url && !$loop->last)
<li class="breadcrumb-item"><a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a></li>
@else
<li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
@endif
@endforeach
</ol>
@endif
(See the views/ directory for the built-in templates.)
The view will receive an array called $breadcrumbs
.
Each breadcrumb is an object with the following keys:
title
– The breadcrumb titleurl
– The breadcrumb URL, ornull
if none was given- Plus additional keys for each item in
$data
(see Custom data)
Then update your config file (config/breadcrumbs.php
) with the custom view name, e.g.:
'view' => 'partials.breadcrumbs', #--> resources/views/partials/breadcrumbs.blade.php
Alternatively you can skip the custom view and call Breadcrumbs::generate()
to get the breadcrumbs Collection directly:
@foreach (Breadcrumbs::generate('post', $post) as $breadcrumb)
{{-- ... --}}
@endforeach
Call Breadcrumbs::render()
in the view template for each page, passing it the name of the breadcrumb to use and any additional parameters.
In the page (e.g. resources/views/home.blade.php
):
{{ Breadcrumbs::render('home') }}
Or with a parameter:
{{ Breadcrumbs::render('category', $category) }}
In the page (e.g. resources/views/home.blade.php
):
@extends('layout.name')
@section('breadcrumbs', Breadcrumbs::render('home'))
In the layout (e.g. resources/views/app.blade.php
):
@yield('breadcrumbs')
In the page (e.g. resources/views/home.php
):
<?= Breadcrumbs::render('home') ?>
Or use the long-hand syntax if you prefer:
<?php echo Breadcrumbs::render('home') ?>
To render breadcrumbs as JSON-LD structured data (usually for SEO reasons), use Breadcrumbs::view()
to render the breadcrumbs::json-ld
template in addition to the normal one. For example:
<html>
<head>
...
{{ Breadcrumbs::view('breadcrumbs::json-ld', 'category', $category) }}
...
</head>
<body>
...
{{ Breadcrumbs::render('category', $category) }}
...
</body>
</html>
To specify an image, add it to the $data
parameter in push()
:
Breadcrumbs::register('post', function ($breadcrumbs, $post) {
$breadcrumbs->parent('home');
$breadcrumbs->push($post->title, route('post', $post), ['image' => asset($post->image)]);
});
(If you prefer to use Microdata or RDFa you will need to create a custom template.)
In normal usage you must call Breadcrumbs::render($name, $params...)
to render the breadcrumbs on every page. If you prefer, you can name your breadcrumbs the same as your routes and avoid this duplication...
Make sure each of your routes has a name. For example (routes/web.php
):
// Home
Route::name('home')->get('/', 'HomeController@index');
// Home > [Post]
Route::name('post')->get('/post/{id}', 'PostController@show');
For more details see Named Routes in the Laravel documentation.
For each route, create a breadcrumb with the same name and parameters. For example (routes/breadcrumbs.php
):
// Home
Breadcrumbs::register('home', function ($breadcrumbs) {
$breadcrumbs->push('Home', route('home'));
});
// Home > [Post]
Breadcrumbs::register('post', function ($breadcrumbs, $id) {
$post = Post::findOrFail($id);
$breadcrumbs->parent('home');
$breadcrumbs->push($post->title, route('post', $post));
});
To add breadcrumbs to a custom 404 Not Found page, use the name errors.404
:
// Error 404
Breadcrumbs::register('errors.404', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('Page Not Found');
});
Call Breadcrumbs::render()
with no parameters in your layout file (e.g. resources/views/app.blade.php
):
{{ Breadcrumbs::render() }}
This will automatically output breadcrumbs corresponding to the current route. The same applies to Breadcrumbs::generate()
:
$breadcrumbs = Breadcrumbs::generate();
And to Breadcrumbs::view()
:
{{ Breadcrumbs::view('breadcrumbs::json-ld') }}
It will throw an InvalidBreadcrumbException
if the breadcrumb doesn't exist, to remind you to create one. To prevent this, first initialise the config file, if you haven't already:
php artisan vendor:publish --provider="DaveJamesMiller\Breadcrumbs\BreadcrumbsServiceProvider"
Then open config/breadcrumbs.php
and set this value:
'missing-route-bound-breadcrumb-exception' => false,
Similarly to prevent it throwing an UnnamedRouteException
if the current route doesn't have a name set this value:
'unnamed-route-exception' => false,
Laravel Breadcrumbs uses the same model binding as the controller. For example:
// routes/web.php
Route::name('post')->get('/post/{post}', 'PostController@show');
// app/Http/Controllers/PostController.php
use App\Post;
class PostController extends Controller
{
public function show(Post $post) // <-- Implicit model binding happens here
{
return view('post/show', ['post' => $post]);
}
}
// routes/breadcrumbs.php
Breadcrumbs::register('post', function ($breadcrumbs, $post) { // <-- The same Post model is injected here
$breadcrumbs->parent('home');
$breadcrumbs->push($post->title, route('post', $post));
});
This makes your code less verbose and more efficient by only loading the post from the database once.
For more details see Route Model Binding in the Laravel documentation.
Laravel automatically creates route names for resourceful controllers, e.g. photo.index
, which you can use when defining your breadcrumbs. For example:
// routes/web.php
Route::resource('photo', PhotoController::class);
$ php artisan route:list
+--------+----------+--------------------+---------------+-------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+--------------------+---------------+-------------------------+------------+
| | GET|HEAD | photo | photo.index | PhotoController@index | |
| | GET|HEAD | photo/create | photo.create | PhotoController@create | |
| | POST | photo | photo.store | PhotoController@store | |
| | GET|HEAD | photo/{photo} | photo.show | PhotoController@show | |
| | GET|HEAD | photo/{photo}/edit | photo.edit | PhotoController@edit | |
| | PUT | photo/{photo} | photo.update | PhotoController@update | |
| | PATCH | photo/{photo} | | PhotoController@update | |
| | DELETE | photo/{photo} | photo.destroy | PhotoController@destroy | |
+--------+----------+--------------------+---------------+-------------------------+------------+
// routes/breadcrumbs.php
// Photos
Breadcrumbs::register('photo.index', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('Photos', route('photo.index'));
});
// Photos > Upload Photo
Breadcrumbs::register('photo.create', function ($breadcrumbs) {
$breadcrumbs->parent('photo.index');
$breadcrumbs->push('Upload Photo', route('photo.create'));
});
// Photos > [Photo Name]
Breadcrumbs::register('photo.show', function ($breadcrumbs, $photo) {
$breadcrumbs->parent('photo.index');
$breadcrumbs->push($photo->title, route('photo.show', $photo->id));
});
// Photos > [Photo Name] > Edit Photo
Breadcrumbs::register('photo.edit', function ($breadcrumbs, $photo) {
$breadcrumbs->parent('photo.show', $photo);
$breadcrumbs->push('Edit Photo', route('photo.edit', $photo->id));
});
For more details see Resource Controllers in the Laravel documentation.
The second parameter to push()
is optional, so if you want a breadcrumb with no URL you can do so:
$breadcrumbs->push('Sample');
The $breadcrumb->url
value will be null
.
The default Twitter Bootstrap templates provided render this with a CSS class of "active", the same as the last breadcrumb, because otherwise they default to black text not grey which doesn't look right.
The push()
method accepts an optional third parameter, $data
– an array of arbitrary data to be passed to the breadcrumb, which you can use in your custom template. For example, if you wanted each breadcrumb to have an icon, you could do:
$breadcrumbs->push('Home', '/', ['icon' => 'home.png']);
The $data
array's entries will be merged into the breadcrumb as properties, so you would access the icon as $breadcrumb->icon
in your template, like this:
<li><a href="{{ $breadcrumb->url }}">
<img src="/images/icons/{{ $breadcrumb->icon }}">
{{ $breadcrumb->title }}
</a></li>
Do not use the keys title
or url
as they will be overwritten.
You can register "before" and "after" callbacks to add breadcrumbs at the start/end of the trail. For example, to automatically add the current page number at the end:
Breadcrumbs::after(function ($breadcrumbs) {
$page = (int) request('page', 1);
if ($page > 1) {
$breadcrumbs->push("Page $page");
}
});
To get the last breadcrumb for the current page, use Breadcrumb::current()
. For example, you could use this to output the current page title:
<title>{{ ($breadcrumb = Breadcrumbs::current()) ? $breadcrumb->title : 'Fallback Title' }}</title>
To ignore a breadcrumb, add 'current' => false
to the $data
parameter in push()
. This can be useful to ignore pagination breadcrumbs:
Breadcrumbs::after(function ($breadcrumbs) {
$page = (int) request('page', 1);
if ($page > 1) {
$breadcrumbs->push("Page $page", null, ['current' => false]);
}
});
<title>
{{ ($breadcrumb = Breadcrumbs::current()) ? "$breadcrumb->title –" : '' }}
{{ ($page = (int) request('page')) > 1 ? "Page $page –" : '' }}
Demo App
</title>
For more advanced filtering, use Breadcrumbs::generate()
and Laravel's Collection class methods instead:
$current = Breadcrumbs::generate()->where('current', '!==', 'false)->last();
You can use Breadcrumbs::view()
in place of Breadcrumbs::render()
to render a template other than the default one:
{{ Breadcrumbs::view('partials.breadcrumbs2', 'category', $category) }}
Or you can override the config setting to affect all future render()
calls:
Config::set('breadcrumbs.view', 'partials.breadcrumbs2');
{{ Breadcrumbs::render('category', $category) }}
Or you could call Breadcrumbs::generate()
to get the breadcrumbs Collection and load the view manually:
@include('partials.breadcrumbs2', ['breadcrumbs' => Breadcrumbs::generate('category', $category)])
If you call Breadcrumbs::render()
or Breadcrumbs::generate()
with no parameters, it will use the current route name and parameters by default (as returned by Laravel's Route::current()
method).
You can override this by calling Breadcrumbs::setCurrentRoute($name, $param1, $param2...)
.
To check if a breadcrumb with a given name exists, call Breadcrumbs::exists('name')
, which returns a boolean.
If you don't want to use routes/breadcrumbs.php
, you can change it in the config file. First initialise the config file, if you haven't already:
php artisan vendor:publish --provider="DaveJamesMiller\Breadcrumbs\BreadcrumbsServiceProvider"
Then open config/breadcrumbs.php
and edit this line:
'files' => base_path('routes/breadcrumbs.php'),
It can be an absolute path, as above, or an array:
'files' => [
base_path('breadcrumbs/admin.php'),
base_path('breadcrumbs/frontend.php'),
],
So you can use glob()
to automatically find files using a wildcard:
'files' => glob(base_path('breadcrumbs/*.php')),
Or return an empty array []
to disable loading.
If you are creating your own package, simply load your breadcrumbs file from your service provider's boot()
method:
use Illuminate\Support\ServiceProvider;
class MyServiceProvider extends ServiceProvider
{
public function register() {}
public function boot()
{
if (class_exists('Breadcrumbs')) {
require __DIR__ . '/breadcrumbs.php';
}
}
}
You can use dependency injection to access the BreadcrumbsManager
instance if you prefer, instead of using the Breadcrumbs::
facade:
use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager;
use Illuminate\Support\ServiceProvider;
class MyServiceProvider extends ServiceProvider
{
public function register() {}
public function boot(BreadcrumbsManager $breadcrumbs)
{
$breadcrumbs->register(...);
}
}
The BreadcrumbsManager class is macroable, so you can add your own methods. For example:
Breadcrumbs::macro('pageTitle', function () {
$title = ($breadcrumb = Breadcrumbs::current()) ? "{$breadcrumb->title} – " : '';
if (($page = (int) request('page')) > 1) {
$title .= "Page $page – ";
}
return $title . 'Demo App';
});
<title>{{ Breadcrumbs::pageTitle() }}</title>
For more advanced customisations you can subclass BreadcrumbsManager and/or BreadcrumbsGenerator, then update the config file with the new class name:
// Manager
'manager-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsManager::class,
// Generator
'generator-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator::class,
(Note: Anything that's not part of the public API (see below) may change between releases, so I suggest you write unit tests to ensure it doesn't break when upgrading.)
Method | Returns | Added in |
---|---|---|
Breadcrumbs::register(string $name, closure $callback) |
(none) | 1.0.0 |
Breadcrumbs::before(closure $callback) |
(none) | 4.0.0 |
Breadcrumbs::after(closure $callback) |
(none) | 4.0.0 |
Breadcrumbs::exists() |
boolean | 2.2.0 |
Breadcrumbs::exists(string $name) |
boolean | 2.2.0 |
Breadcrumbs::generate() |
Collection | 2.2.3 |
Breadcrumbs::generate(string $name) |
Collection | 1.0.0 |
Breadcrumbs::generate(string $name, mixed $param1, ...) |
Collection | 1.0.0 |
Breadcrumbs::render() |
string | 2.2.0 |
Breadcrumbs::render(string $name) |
string | 1.0.0 |
Breadcrumbs::render(string $name, mixed $param1, ...) |
string | 1.0.0 |
Breadcrumbs::view(string $view) |
string | 4.0.0 |
Breadcrumbs::view(string $view, string $name) |
string | 4.0.0 |
Breadcrumbs::view(string $view, string $name, mixed $param1, ...) |
string | 4.0.0 |
Breadcrumbs::setCurrentRoute(string $name) |
(none) | 2.2.0 |
Breadcrumbs::setCurrentRoute(string $name, mixed $param1, ...) |
(none) | 2.2.0 |
Breadcrumbs::clearCurrentRoute() |
(none) | 2.2.0 |
use App\Models\Post;
use DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator;
Breadcrumbs::before('name', function (BreadcrumbsGenerator $breadcrumbs) {
// ...
});
Breadcrumbs::register('name', function (BreadcrumbsGenerator $breadcrumbs, Post $post) {
// ...
});
Breadcrumbs::after('name', function (BreadcrumbsGenerator $breadcrumbs) {
// ...
});
Method | Returns | Added in |
---|---|---|
$breadcrumbs->push(string $title) |
(none) | 1.0.0 |
$breadcrumbs->push(string $title, string $url) |
(none) | 1.0.0 |
$breadcrumbs->push(string $title, string $url, array $data) |
(none) | 2.3.0 |
$breadcrumbs->parent(string $name) |
(none) | 1.0.0 |
$breadcrumbs->parent(string $name, mixed $param1, ...) |
(none) | 1.0.0 |
@foreach ($breadcrumbs as $breadcrumb)
{{-- ... --}}
@endforeach
Variable | Type | Added in |
---|---|---|
$breadcrumb->title |
string | 1.0.0 |
$breadcrumb->url |
string / null | 1.0.0 |
$breadcrumb->custom_attribute_name |
mixed | 2.3.0 |
Setting | Type | Added in |
---|---|---|
view |
string | 2.0.0 |
files |
string / array | 4.0.0 |
unnamed-route-exception |
boolean | 4.0.0 |
missing-route-bound-breadcrumb-exception |
boolean | 4.0.0 |
invalid-named-breadcrumb-exception |
boolean | 4.0.0 |
manager-class |
string | 4.2.0 |
generator-class |
string | 4.2.0 |
Laravel Breadcrumbs uses Semantic Versioning.
v4.2.0 (Thu 14 Sep 2017)
- Add
manager-class
andgenerator-class
config options
v4.1.0 (Mon 28 Aug 2017)
- Add Bulma template
v4.0.0 (Fri 25 Aug 2017)
- Add Laravel 5.5 support, and drop support for Laravel 5.4 and below (future versions will target a single Laravel release to simplify testing and documentation)
- Add package auto-discovery
- Add Bootstrap 4 template and set it as the default
- Add Foundation 6 and Materialize templates
- Add
Breadcrumbs::view()
method to render breadcrumbs with a specific view - Add
Breadcrumbs::before()
andBreadcrumbs::after()
methods - Add type hints to all methods (parameters and return value)
- Add more specific exception classes:
DuplicateBreadcrumbException
InvalidBreadcrumbException
InvalidViewException
UnnamedRouteException
- Use
errors.404
breadcrumb for custom Error 404 pages, instead of no breadcrumbs - Change
Breadcrumbs::generate()
to return a Collection instead of an array - Rename classes to make them easier to reference in an IDE
Manager
→BreadcrumbsManager
Generator
→BreadcrumbsGenerator
ServiceProvider
→BreadcrumbsServiceProvider
Exception
→BreadcrumbsException
Facade
→Facades\Breadcrumbs
- Remove
$breadcrumbs->first
and$breadcrumbs->last
in views (use Blade's$loop->first
and$loop->last
instead) - Remove
Array
variants of methods – use variadic arguments instead:Breadcrumbs::renderArray($page, $params)
→Breadcrumbs::render($page, ...$params)
Breadcrumbs::generateArray($page, $params)
→Breadcrumbs::generate($page, ...$params)
Breadcrumbs::setCurrentRouteArray($name, $params)
→Breadcrumbs::setCurrentRoute($page, ...$params)
$breadcrumbs->parentArray($name, $params)
→$breadcrumbs->parent($name, ...$params)
- Remove
IfExists
variants of methods – set new config settings tofalse
instead:unnamed-route-exception
– when route-bound breadcrumbs are used but the current route doesn't have a namemissing-route-bound-breadcrumb-exception
– when route-bound breadcrumbs are used and the matching breadcrumb doesn't existinvalid-named-breadcrumb-exception
– when a named breadcrumbs is used doesn't exist
- Remove
Breadcrumbs::setView($view)
(useConfig::set('breadcrumbs.view', $view)
instead) - Remove
app/Http/breadcrumbs.php
file loading (useroutes/breadcrumbs.php
, or change thefiles
setting in the config file) - Remove
laravel-breadcrumbs::
view prefix (usebreadcrumbs::
instead) - Remove
$app['breadcrumbs']
container short name (useBreadcrumbs::
facade orDaveJamesMiller\Breadcrumbs\BreadcrumbsManager
type hint) - Greatly improved unit tests
- Remove the
ServiceProvider
andFacade
fromconfig/app.php
- Upgrade to Laravel 5.5 (requires PHP 7.0+)
- If using Bootstrap 3, make sure you have selected the Bootstrap 3 template in the config file
- If using
renderIfExists()
, switch torender()
and disable exceptions in the config file - If using
renderArray()
, switch torender()
and variadic arguments
Sorry, I don't offer free technical support. I spent a lot of time building Laravel Breadcrumbs and writing documentation, and I give it to you for free. Please don't expect me to also solve your problems for free.
I strongly believe that spending time fixing your own problems is the best way to learn, but if you're really stuck, I suggest you try posting a question on Stack Overflow, Laravel.io Forum or Laracasts Forum.
If you really need my help and are willing to pay for it, please email me. (Make sure it's clear you're looking for paid support, else I'll probably ignore your email.)
Please open an issue on GitHub. But remember this is free software, so I don't guarantee to fix any bugs – I will investigate if/when I have the time and motivation to do so. Don't be afraid to go into the Laravel Breadcrumbs code (vendor/davejamesmiller/laravel-breadcrumbs/src/
), use var_dump()
to see what's happening and fix your own problems!
Bug fixes: Please fix it and open a pull request. Bonus points if you add a unit test to make sure it doesn't happen again!
New features: Only high value features with a clear use case and well-considered API will be accepted. They must be documented and include unit tests. I suggest you open an issue to discuss the idea first.
Documentation: If you think the documentation can be improved in any way, please do edit this file and make a pull request.
The easiest way to work on Laravel Breadcrumbs inside a real Laravel application is to tell Composer to install from source (Git) using the --prefer-source
flag:
cd /path/to/repo
rm -rf vendor/davejamesmiller/laravel-breadcrumbs
composer install --prefer-source
Then:
cd vendor/davejamesmiller/laravel-breadcrumbs
git checkout -t origin/master
git checkout -b YOUR_BRANCH
# Make changes and commit them
git remote add YOUR_USERNAME git@github.com:YOUR_USERNAME/laravel-breadcrumbs
git push -u YOUR_USERNAME YOUR_BRANCH
Alternatively there is a test app that you can use.
To run the unit tests, simply run:
cd /path/to/laravel-breadcrumbs
composer update
scripts/test.sh
To check code coverage, you will also need Xdebug installed. Run:
scripts/test-coverage.sh
Then open test-coverage/index.html
to view the results. Be aware of the edge cases in PHPUnit that can make it not-quite-accurate.
To use your own fork in a project, update the composer.json
in your main project as follows:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/YOUR_USERNAME/laravel-breadcrumbs.git"
}
],
"require": {
"davejamesmiller/laravel-breadcrumbs": "dev-YOUR_BRANCH"
}
}
Replace YOUR_USERNAME
with your GitHub username and YOUR_BRANCH
with the branch name (e.g. develop
). This tells Composer to use your repository instead of the default one.
Copyright © 2013-2017 Dave James Miller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.