PHP code example of domprojects / codeigniter4-breadcrumb

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

    

domprojects / codeigniter4-breadcrumb example snippets




$breadcrumb = single_service('breadcrumb');

$breadcrumb
    ->add('Home', url_to('home'))
    ->add('Blog', url_to('blog.index'))
    ->add('Article');

echo $breadcrumb->render();



namespace App\Controllers;

use domProjects\CodeIgniterBreadcrumb\Traits\HasBreadcrumb;
use CodeIgniter\Controller;

abstract class BaseController extends Controller
{
    use HasBreadcrumb;
}



$this
    ->breadcrumbRoot('Home', url_to('home'))
    ->breadcrumbController('Blog', 'blog.index')
    ->breadcrumbAppend('Article');

$data['breadcrumb'] = $this->renderBreadcrumb();



$data['breadcrumb'] = $this->renderBreadcrumb(
    $this->getBreadcrumbTemplate('backend')
);
text
src/
  Breadcrumb.php
  Config/
    Breadcrumb.php
    Services.php
  Traits/
    HasBreadcrumb.php