1. Go to this page and download the library: Download daikazu/breadcrumbs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daikazu / breadcrumbs example snippets
// app/Providers/AppServiceProvider.php
use Daikazu\Breadcrumbs\Facades\Breadcrumbs;
use Daikazu\Breadcrumbs\Trail;
public function boot(): void
{
Breadcrumbs::for('home', function (Trail $trail) {
$trail->push('Home', route('home'));
});
Breadcrumbs::for('about', function (Trail $trail) {
$trail->parent('home')->push('About', route('about'));
});
}
use Daikazu\Breadcrumbs\Facades\Breadcrumbs;
use Daikazu\Breadcrumbs\Trail;
Breadcrumbs::for('products.index', function (Trail $trail) {
$trail->push('Home', route('home'))
->push('Products', route('products.index'));
});
Breadcrumbs::for('orders.items.show', function (Trail $trail, Order $order, OrderItem $item) {
$trail->parent('orders.show', $order)
->push("Item #{$item->id}", route('orders.items.show', [$order, $item]));
});
Breadcrumbs::for('blog.post', function (Trail $trail, $post) {
$trail->parent('blog.index')
->push($post->title, route('blog.post', $post->slug));
});
// In a controller or view where $post is already loaded:
Breadcrumbs::current($post);
// function (Trail $trail, $category, $product)
Breadcrumbs::current($category, $product);
use Daikazu\Breadcrumbs\Contracts\HasBreadcrumb;
use Daikazu\Breadcrumbs\Trail;
class Product extends Model implements HasBreadcrumb
{
public function toBreadcrumb(Trail $trail): void
{
$trail->parent('products.index')
->push($this->name, route('products.show', $this));
}
}
'view' => 'breadcrumbs::bootstrap5',
'view' => 'breadcrumbs::tailwind', // or your own view name after customizing
Breadcrumbs::for('about', function (Trail $trail) {
$trail->home()->push('About', route('about'));
});
// app/Providers/AppServiceProvider.php
use Laravel\Octane\Events\RequestTerminated;
public function boot(): void
{
$this->app['events']->listen(RequestTerminated::class, function () {
app('breadcrumbs')->flush();
});
}