mateusjatenee / laravel-breadcumb
PHP project.
Requires
- php: >=7.0
- illuminate/container: ~5.1.0|~5.2.0|~5.3.0|~5.4.0
- illuminate/support: ~5.1.0|~5.2.0|~5.3.0|~5.4.0
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/testbench: ~3.3.0|~3.4.0
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-10-25 07:04:08 UTC
README
This package allows you to generate HTML for breadcumbs. Here's an example:
Breadcrumb::generate('users.show')
results on this using the Bootstrap Driver
<ol class="breadcrumb"><li><span>Users</span></li><li class="active"><span>Show</span></li></ol>
You may write your own drivers. This will be documented soon.
Installation
This package can be installed through Composer.
$ composer require mateusjatenee/laravel-breadcrumbs
Add the following service provider
// config/app.php 'providers' => [ ... Mateusjatenee\Breadcrumb\BreadcrumbServiceProvider::class, ... ];
This package also comes with a facade, which provides an easy way to call the the class.
// config/app.php 'aliases' => [ ... 'Breadcrumb' => Mateusjatenee\Breadcrumb\Facades\Breadcrumb::class, ... ];
You may register your drivers with the following code in a service provider's boot
method
Breadcumb::addDriver('driverName', DriverClass::class);
And you may switch the default driver with the following code
Breadcumb::setDriver('driverName');
Writing Drivers
Writing a driver is pretty simple. You just have to create a class that extends Mateusjatenee\Breadcrumb\BreadcrumbGenerator
and implements Mateusjatenee\Breadcrumb\Contracts\BreadcrumbDriverContract
and add the following methods: getParentTags
, getItemTags
, getLastItemTags
. Example:
<?php class BootstrapDriver extends BreadcrumbGenerator implements BreadcrumbDriverContract { public function getParentTags() { return '<ol class="breadcrumb">{content}</ol>'; } public function getItemTags() { return '<li><span>{item}</span></li>'; } public function getLastItemTags() { return '<li class="active"><span>{item}</span></li>'; } } ?>
The package will automatically use that information to generate your HTML.
Running tests
$ composer test
License
This library is licensed under the MIT license. Please see LICENSE for more details.
Changelog
Please see CHANGELOG for more details.
Contributing
Please see CONTRIBUTING for more details.