Breadcrumb
This package allows you to easily build a breadcrumb from PHP., (*1)
Requirements
This package requires PHP 7 and the renderers make use of vdhicts/html-element., (*2)
Installation
This package can be used in any PHP project or with any framework., (*3)
You can install the package via composer:, (*4)
``` bash
composer require vdhicts/breadcrumb-builder, (*5)
## Usage
```php
use Vdhicts\Dicms\Breadcrumb;
// Create breadcrumb items
$applicationItem = new Breadcrumb\Item('Application', null, 'bars'); // without link, with icon
$pageItem = new Breadcrumb\Item('Page', 'http://www.example.com/page'); // with link, without icon
$actionItem = new Breadcrumb\Item('Add', 'http://www.example.com/page/add', 'plus'); // with link, with icon
// Start the item collection
$itemCollection = new Breadcrumb\ItemCollection();
// Add multiple items at once
$itemCollection->setItems([
$applicationItem,
$pageItem
]);
// Add a single item
$itemCollection->addItem($actionItem);
// Boot the renderer
$renderer = new Breadcrumb\Renderers\Bootstrap3();
// Boot the builder with the collection and renderer
$builder = new Breadcrumb\Builder($itemCollection, $renderer);
// Generate the breadcrumb
$builder->generate();
Renderers
There are 2 renderers available by default, for Bootstrap 3 and Bootstrap 4:, (*6)
Bootstrap 3
<ol class="breadcrumb">
<li>
<i class="fa fa-fw fa-bars"></i> Application
</li>
<li>
<a href="http://www.example.com/page">Page</a>
</li>
<li class="active">
<a href="http://www.example.com/page/add"><i class="fa fa-fw fa-plus"></i> Add</a>
</li>
</ol>
Bootstrap 4
<ol class="breadcrumb">
<li class="breadcrumb-item">
<i class="fa fa-fw fa-bars"></i> Application
</li>
<li class="breadcrumb-item">
<a href="http://www.example.com/page">Page</a>
</li>
<li class="breadcrumb-item active">
<a href="http://www.example.com/page/add"><i class="fa fa-fw fa-plus"></i> Add</a>
</li>
</ol>
Custom renderer
You can use your own renderer as long as it implements the Renderer
interface., (*7)
Tests
Full code coverage unit tests are available in the tests
folder. Run via phpunit:, (*8)
vendor\bin\phpunit
, (*9)
By default a coverage report will be generated in the build/coverage
folder., (*10)
Contribution
Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request
per feature. In exchange you will be credited as contributor on this page., (*11)
Security
If you discover any security related issues in this or other packages of Vdhicts, please email info@vdhicts.nl instead
of using the issue tracker., (*12)
License
This package is open-sourced software licensed under the MIT license., (*13)
About vdhicts
Van der Heiden ICT services is the name of my personal company for which I work as
freelancer. Van der Heiden ICT services develops and implements IT solutions for businesses and educational
institutions., (*14)