{"id":16266460,"url":"https://github.com/thormeier/breadcrumb-bundle","last_synced_at":"2025-09-19T18:52:00.446Z","repository":{"id":32858662,"uuid":"36452430","full_name":"thormeier/breadcrumb-bundle","owner":"thormeier","description":"Symfony bundle for easy breadcrumbs management","archived":false,"fork":false,"pushed_at":"2023-01-30T14:08:34.000Z","size":62,"stargazers_count":28,"open_issues_count":2,"forks_count":20,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-11T08:25:45.301Z","etag":null,"topics":["breadcrumbs","bundle","php","symfony","symfony-bundle","twig","twig-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thormeier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-28T16:45:21.000Z","updated_at":"2025-08-01T15:59:06.000Z","dependencies_parsed_at":"2023-02-16T08:15:28.313Z","dependency_job_id":null,"html_url":"https://github.com/thormeier/breadcrumb-bundle","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/thormeier/breadcrumb-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fbreadcrumb-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fbreadcrumb-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fbreadcrumb-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fbreadcrumb-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thormeier","download_url":"https://codeload.github.com/thormeier/breadcrumb-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fbreadcrumb-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275988718,"owners_count":25565641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["breadcrumbs","bundle","php","symfony","symfony-bundle","twig","twig-extension"],"created_at":"2024-10-10T17:41:57.808Z","updated_at":"2025-09-19T18:52:00.413Z","avatar_url":"https://github.com/thormeier.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"BreadcrumbBundle\n================\n\n[![Build Status](https://travis-ci.org/thormeier/breadcrumb-bundle.png?branch=master)](https://travis-ci.org/thormeier/breadcrumb-bundle)\n\n## Introduction\n\nThis Symfony bundle provides integration of breadcrumbs via route config and rendering in your Twig templates.\nThis bundle is heavily inspired by the inactive https://github.com/xi-project/xi-bundle-breadcrumbs\n\n## Installation\n\n### Step 1: Composer require\n\n    $ php composer.phar require \"thormeier/breadcrumb-bundle\"\n\n### Step2: Enable the bundle in the kernel\n\n    \u003c?php\n    // app/AppKernel.php\n    \n    public function registerBundles()\n    {\n        $bundles = array(\n            // ...\n            new Thormeier\\BreadcrumbBundle\\ThormeierBreadcrumbBundle(),\n            // ...\n        );\n    }\n\n## Configuration\n\nEnable the bundle in your config.yml:\n\n    # config.yml\n    thormeier_breadcrumb: ~\n\nThe template defaults to a very basic one, providing a `\u003cul\u003e` with `\u003cli\u003e` and `\u003ca\u003e` for every breadcrumb.\n\n## Usage\n\n### Basic\n\nA breadcrumb tree is created by the fields `label` and `parent_route` in the `defaults` of a route. Basic tree example:\n\n    # routing.yml\n    \n    acme_demo_home:\n        path: /\n        options:\n            breadcrumb:\n                label: Home\n    \n    acme_demo_contact:\n        path: /contact\n        options:\n            breadcrumb:\n                label: Contact\n                parent_route: acme_demo_home\n    \n    acme_demo_catalogue:\n        path: /catalogue\n        options:\n            breadcrumb:\n                label: 'Our Catalogue'\n                parent_route: acme_demo_home\n    \n    acme_demo_catalogue_categories:\n        path: /catalogue/categories\n        options:\n            breadcrumb:\n                label: 'All categories'\n                parent_route: acme_demo_catalogue\n\nWould result in a breadcrumb tree like:\n\n    acme_demo_home\n        |- acme_demo_contact\n        `- acme_demo_catalogue\n           `- acme_demo_catalogue_categories\n\nIf the current route is `acme_demo_catalogue`, the breadcrumbs would for instance show the following:\n\n    Home \u003e Our Catalogue\n\nSince the configuration of the breadcrumbs happens on routing config, it's generally agnostic from _how_ the routing \nconfiguration happens. This means that configuring breadcrumbs for instance via annotations is perfectly possible:\n\n    /**\n     * ...\n     * @Route(\n     *    \"/contact\",\n     *    name=\"acme_demo_contact\",\n     *    options={\n     *        \"breadcrumb\" = {\n     *            \"label\" = \"Contact\",\n     *            \"parent_route\" = \"acme_demo_home\"\n     *        }\n     *    })\n     * ...\n     */\n\nThe configuration can also be done in XML and PHP.\n\n### Dynamic routes\n\nIf you happen to have dynamic routes or dynamic translations that you need in your breadcrumbs, they \ncan be defined like so:\n\n    # routing.yml\n    \n    acme_demo_product_detail:\n        path: /products/{id}\n        options:\n            breadcrumb:\n                label: 'Produkt: %%name%%'\n                parent_route: acme_demo_catalogue\n\n(This example uses a string with a placeholder in the routing directly. You can also define the label text in a \ntranslation file and only use the translation key as the label. The template will handle the translation and \nreplacing.)\n\n**Notice the double `%` to escape the parameter in the label. This needs to be done, because `routing.yml` \nis being parsed by the Symfony container and recognizes constructs, such as `%name%` as a container parameter \nand tries to inject those. The double-`%` escapes it, the template is handling the rest.**\n\nYou can then set parameters for both directly on the `Breadcrumb` object, for instance:\n\n    \u003c?php\n    // MyController\n    \n    // ...\n    \n    public function productDetailAction()\n    {\n        $product = ...;\n    \n        // ...\n    \n        $this-\u003eget('thormeier_breadcrumb.breadcrumb_provider')\n            -\u003egetBreadcrumbByRoute('acme_demo_product_detail')\n            -\u003esetRouteParams(array(\n                'id' =\u003e $product-\u003egetId(),\n            ))\n            -\u003esetLabelParams(array(\n                'name' =\u003e $product-\u003egetName(),\n            ));\n            \n        // ...\n    }\n\nPlease note that the breadcrumb must be defined on the route in order to set parameters.\n\n### Dynamic breadcrumbs\n\nIf you happen to have a dynamic routing tree, for instance a tree of category pages that can go infinitely deep, \nyou can add breadcrumbs that are not defined on a route on the fly. For instance like this:\n\n    \u003c?php\n    \n    use Thormeier\\BreadcrumbBundle\\Model\\Breadcrumb;\n    \n    // ...\n    \n    // Route of the product, we want the categories before this\n    $productCrumb = $breadcrumbProvder-\u003egetBreadcrumbByRoute('acme_demo_product_detail');\n    $collection = $breadcrumbProvider-\u003egetBreadcrumbs();\n    \n    foreach ($product-\u003egetCategories() as $category) {\n        $newCrumb = new Breadcrumb(\n            'Category: %name%',              // Label\n            'acme_demo_category',            // Route\n            ['id' =\u003e $category-\u003egetId()],    // Route params\n            ['name' =\u003e $category-\u003egetName()] // Label params\n        );\n        \n        // Adds $newCrumb right in front of $productCrumb\n        $collection-\u003eaddBreadcrumbBeforeCrumb($newCrumb, $productCrumb);\n        \n        // Or: -\u003eaddBreadcrumb(), -\u003eaddBreadcrumbAtPosition(), -\u003eaddBreadcrumbAfterCrumb(), -\u003eaddBreadcrumbToStart()\n    }\n\nThese breadcrumbs are not stored in the cache though.\n\n### Displaying in twig\n\nCall the twig extension as following:\n\n    {# someTemplate.html.twig #}\n    {# ... #}\n    \n    {{ breadcrumbs() }}\n    \n    {# ... #}\n\n### Using the bootstrap template\n\nThe bundle also provides a default implementation for [Bootstrap](https://getbootstrap.com/docs/4.3/components/breadcrumb/). It can be used as follows:\n\n    # config.yml\n    thormeier_breadcrumb:\n        template: @ThormeierBreadcrumb/breadcrumbs_bootstrap.html.twig\n\n### Replacing the default template\n\nIf you want to use a custom template, add the following to your config.yml\n\n    # config.yml\n    thormeier_breadcrumb:\n        template: 'my twig template path'\n\nYour custom breadcrumb template receives a variable called `breadcrumbs` that is a collection that represents your \nbreadcrumbs, ordered by highest in the tree to lowest.\n\nA single `breadcrumb` has the fields `route`, `routeParameters`, `label` and `labelParameters`. `route` and `routeParameters` \nare used to generate a path in twig, i.e. `path(breadcrumb.route, breadcrumb.routeParameters)`, whereas `label` and \n`labelParameters` are used to generate the text for the breadcrumb, i.e. \n`{{ (breadcrumb.label)|trans(breadcrumb.labelParameters) }}`\n\nYour custom template might look something like this:\n\n    {# myBreadcrumbs.html.twig #}\n\n    \u003cdiv\u003e\n        {% for breadcrumb in breadcrumbs %}\n            \u003ca href=\"{{ path(breadcrumb.route, breadcrumb.routeParameters) }}\"\u003e\n                {{ breadcrumb.label|replace({\"%%\": \"%\"})|trans(breadcrumb.labelParameters) }}\n            \u003c/a\u003e\n        {% endfor %}\n    \u003c/div\u003e\n\n**The replacing of `%%` with single `%` happens inside the template. See *\"Dynamic routes\"* as why this is needed.**\n\nHave a look at `Resources/views/breadcrumbs.html.twig` and `Resources/views/breadcrumbs_bootstrap.html.twig` to see the default implementations.\n\n### Customize implementations\n\nThe model class and/or its collection can be replaced by own implementations, that implement the \n`Thormeier\\BreadcrumbBundle\\Model\\BreadcrumbInterface` and \n`Thormeier\\BreadcrumbBundle\\Model\\BreadcrumbCollectionInterface`:\n\n    # config.yml\n    thormeier_breadcrumb:\n        model_class: Acme\\Breadcrumbs\\Model\\MyModel\n        collection_class: Acme\\Breadcrumbs\\Model\\MyCollection\n\nThe provider service ID can be replaced by setting the parameter `provider_service_id`\n\n    # config.yml\n    thormeier_breadcrumb:\n        provider_service_id: acme.breadcrumbs.my_provider\n\n### Caching\n\nThis bundle uses the routing cache to store breadcrumb lists per route on `cache:warmup`. They are then turned into \na `BreadcrumbCollection` on demand.\n\n## Slides\n\nA slideshow presenting the bundle and explaining some concepts a little further is available on slideshare: \n[http://www.slideshare.net/Thormeier/thormeierbreadcrumbbundle](http://www.slideshare.net/Thormeier/thormeierbreadcrumbbundle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthormeier%2Fbreadcrumb-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthormeier%2Fbreadcrumb-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthormeier%2Fbreadcrumb-bundle/lists"}