PHP code example of atstudio-tech / breadcrumbs

1. Go to this page and download the library: Download atstudio-tech/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/ */

    

atstudio-tech / breadcrumbs example snippets


public function show(Post $post) {
    crumbs('Posts', '/posts')->add('Show Post #3', 'posts.show', 3);
}

use ATStudio\Breadcrumbs\Breadcrumbs;

Route::get('posts', [PostController::class, 'index'])->crumbs(function (Breadcrumbs $crumbs) {
    $crumbs->add('Posts', '/posts'); // Here we are using a hard-coded URL
});

public function show(Post $post) {
    crumbs('Posts', '/posts')->add('Show Post #3', 'posts.show', [3]); // The third parameter can also be a primitive: `add(..., ..., 3)`
}

use ATStudio\Breadcrumbs\Breadcrumbs;

public function show(Post $post, Breadcrumbs $crumbs) {
    $crumbs->add('Show Post #3', 'posts.show', [3]);
}

use ATStudio\Breadcrumbs\Breadcrumbs;

public function show(Post $post) {
    Breadcrumbs::instance()->add('Show Post #3', 'posts.show', [3]);
}

use ATStudio\Breadcrumbs\Facades\Crumbs;

public function show(Post $post) {
    Crumbs::add('Show Post #3', 'posts.show', [3]);
}

public function show(Post $post) {
    crumbs()->add('Show Post #3', 'posts.show', [3]);
}

[
    'title' => '',
    'path' => '',
    'params' => [], // optional
]

use ATStudio\Breadcrumbs\Breadcrumbs;

public function show(Post $post) {
    crumbs(function (Breadcrumbs $crumbs) {
        $crumbs->add('All Posts', 'posts.index');
        $crumbs->add('Show Post #1', 'posts.show', 1);
    });
}
shell
php artisan vendor:publish --tag="breadcrumbs-config"
shell
php artisan vendor:publish --tag="breadcrumbs-views"
shell
php artisan vendor:publish --tag="breadcrumbs-views"