1. Go to this page and download the library: Download huluti/breadcrumbs-bundle 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/ */
use Huluti\BreadcrumbsBundle\Attribute\Breadcrumb;
#[Breadcrumb(text: 'firstBreadcrumb', route: 'app_main')]
class Controller extends AbstractController{
#[Breadcrumb(text: 'nextBreadcrumb', route: 'app_main')]
#[Breadcrumb(text: 'nextBreadcrumb', url: '/')]
#[Breadcrumb(text: 'nextBreadcrumb {user.name} in {category.name}', route: 'app_main', parameters: ['id' => '{user.id}', 'category' => '{category.name}'])]
public function yourAction(User $user, Category $category)
{
}
}
php
use Huluti\BreadcrumbsBundle\Model\Breadcrumbs;
public function yourAction(User $user, Breadcrumbs $breadcrumbs)
{
// Simple example
$breadcrumbs->addItem("Home", $this->get("router")->generate("index"));
// Example without URL
$breadcrumbs->addItem("Some text without link");
// Example with parameter injected into translation "user.profile"
$breadcrumbs->addItem($txt, $url, ["%user%" => $user->getName()]);
}
php
public function yourAction(Category $category)
{
$breadcrumbs = $this->get("huluti_breadcrumbs");
$node = $category;
while ($node) {
$breadcrumbs->prependItem($node->getName(), "<category URL>");
$node = $node->getParent();
}
}
php
public function yourAction()
{
$breadcrumbs = $this->get("huluti_breadcrumbs");
// Pass "_demo" route name without any parameters
$breadcrumbs->addRouteItem("Demo", "_demo");
// Pass "_demo_hello" route name with route parameters
$breadcrumbs->addRouteItem("Hello Breadcrumbs", "_demo_hello", [
'name' => 'Breadcrumbs',
]);
// Add "homepage" route link at the start of the breadcrumbs
$breadcrumbs->prependRouteItem("Home", "homepage");
}
php
public function yourAction(User $user)
{
$breadcrumbs = $this->get("huluti_breadcrumbs");
// Simple example
$breadcrumbs->prependNamespaceItem("subsection", "Home", $this->get("router")->generate("index"));
// Example without URL
$breadcrumbs->addNamespaceItem("subsection", "Some text without link");
// Example with parameter injected into translation "user.profile"
$breadcrumbs->addNamespaceItem("subsection", $txt, $url, ["%user%" => $user->getName()]);
// Example with route name with