m-adamski / symfony-breadcrumbs-bundle
The Symfony Bundle, which simplifies the process of generating and displaying breadcrumbs
Installs: 911
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.2
- symfony/framework-bundle: ^7.1
- symfony/twig-bundle: ^7.1
Requires (Dev)
- kint-php/kint: ^5.0
- symfony/test-pack: ^1.1
README
The Symfony Bundle, which simplifies the process of generating and displaying breadcrumbs. Compared to previous versions, this one is based on simple methods of creating and adding breadcrumbs.
Installation
Composer can install this bundle:
$ composer require m-adamski/symfony-breadcrumbs-bundle
How to use it?
namespace App\Controller; use App\Model\Breadcrumbs\Breadcrumb; use App\Model\Breadcrumbs\Catalog as BreadcrumbsCatalog; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class DashboardController extends AbstractController { public function __construct( private readonly BreadcrumbsCatalog $breadcrumbsCatalog, ) {} #[Route("/dashboard", name: "dashboard", methods: ["GET"])] public function index(): Response { $this->breadcrumbsCatalog->getDefaultContainer() ->add((new Breadcrumb("Dashboard"))->setRoute("dashboard")); return $this->render("modules/Dashboard/index.html.twig"); } }
The custom Twig function is responsible for displaying breadcrumbs:
<section class="breadcrumbs-container"> {{ breadcrumbs() }} </section>
License
MIT