PHPackages                             nymo/silex-twig-breadcrumb-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. nymo/silex-twig-breadcrumb-extension

ActiveLibrary[Templating &amp; Views](/categories/templating)

nymo/silex-twig-breadcrumb-extension
====================================

Twig breadcrumb extension for use in silex

v3.0.0(7y ago)879.8k↑300%4MITPHPPHP &gt;=7.1CI failing

Since Mar 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nymo/silex-twig-breadcrumb-extension)[ Packagist](https://packagist.org/packages/nymo/silex-twig-breadcrumb-extension)[ Docs](http://github.com/nymo/silex-twig-breadcrumb-extension)[ RSS](/packages/nymo-silex-twig-breadcrumb-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (13)Used By (0)

Twig breadcrumb extension for Silex
===================================

[](#twig-breadcrumb-extension-for-silex)

This is a breadcrumb extension for Twig which includes a breadcrumb service provider for silex for easy and simple use of breadcrumbs in Silex.

[![Packagist](https://camo.githubusercontent.com/144a28b5c7cd17fc5af6455b40366891448df9ff21761543a701380845f91327/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e796d6f2f73696c65782d747769672d62726561646372756d622d657874656e73696f6e2e737667)](https://packagist.org/packages/nymo/silex-twig-breadcrumb-extension)[![Monthly Downloads](https://camo.githubusercontent.com/2fe79e7f9cde6e7179186855f8477713d18d6753630772f71e9992b4e5ae5385/68747470733a2f2f706f7365722e707567782e6f72672f6e796d6f2f73696c65782d747769672d62726561646372756d622d657874656e73696f6e2f642f6d6f6e74686c79)](https://packagist.org/packages/nymo/silex-twig-breadcrumb-extension)[![Build Status](https://camo.githubusercontent.com/607cae9e237df76db4726c1d9a28da347da77353b2186103bdce3916a25fa081/68747470733a2f2f7472617669732d63692e6f72672f6e796d6f2f73696c65782d747769672d62726561646372756d622d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nymo/silex-twig-breadcrumb-extension)[![Coverage Status](https://camo.githubusercontent.com/9b538b32e0300a0e44269e9edc1f83aefc0f7e95211d645c8ebd5eec68c9c070/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e796d6f2f73696c65782d747769672d62726561646372756d622d657874656e73696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/nymo/silex-twig-breadcrumb-extension?branch=master)

New in Version 3.0
------------------

[](#new-in-version-30)

- Support for PHP &gt; 7.1
- Package is using now PSR-4 autoloader
- Method *addItem* in BreadCrumbCollection is now deprecated and will be removed in 3.1 use *addSimpleItem* or *addRouteItem* instead [see below](#usage)

Roadmap
-------

[](#roadmap)

Since Silex get EOL in June 2018 this Extension will be archived, too. No further features will be implemented. **I'm going to migrate the library to Symfony 4 as this is the future road for all Silex applications.**

General Features
----------------

[](#general-features)

- Create easily breadcrumbs in your Silex application
- i18n support
- Configurable separator
- Template override
- Named route support

General Requirements
--------------------

[](#general-requirements)

- Twig
- gettext must be activated in your PHP environment for i8n support since version 1.1.0

### For PHP 5.3

[](#for-php-53)

- Silex 1.x
- silex-twig-breadcrumb-extension in Version 1.x

### For PHP 5.6

[](#for-php-56)

- Silex 2.x
- silex-twig-breadcrumb-extension in Version 2.x

### For PHP &gt; 7.1

[](#for-php--71)

- Silex 2.x
- silex-twig-breadcrumb-extension in Version 3.x

Installation
------------

[](#installation)

### PHP Configuration

[](#php-configuration)

Please make sure that gettext functionality is activated in your PHP environment. For further assistance please refer to the official PHP Manual

### Via composer:

[](#via-composer)

First add the following to your composer.json file

```
"require":{
        "nymo/silex-twig-breadcrumb-extension":"~3.0"
    }

```

Use Version 2.x for Silex 2 with PHP &lt;= 5.6.

#### Silex 1.x

[](#silex-1x)

```
"require":{
        "nymo/silex-twig-breadcrumb-extension":"~1.2"
    }

```

Then run composer update.

### Configure Silex

[](#configure-silex)

I assume you have already a running Silex application with Twig as a template engine. First register the breadcrumb service provider:

```
$app->register(new \nymo\Silex\Provider\BreadCrumbServiceProvider());

```

Then register the Twig breadcrumb extension. You have to define this after your registered the Twig service provider otherwise the application throws an error if you use $app\['twig'\].

```
$app['twig'] = $app->extend('twig', function ($twig, $app) {
    $twig->addExtension(new \nymo\Twig\Extension\BreadCrumbExtension($app));

    return $twig;
});

```

#### Silex 1.x

[](#silex-1x-1)

```
$app['twig'] = $app->share(
    $app->extend(
        'twig',
        function ($twig, $app) {
            $twig->addExtension(new \nymo\Twig\Extension\BreadCrumbExtension($app));
            return $twig;
        }
    )
);

```

That's all. Now you ready to go.

Usage
-----

[](#usage)

After your successfull installation you can add breadcrumb items wherever you want. All you need is to call the breadcrumb service and add a item:

### New style

[](#new-style)

```
$app['breadcrumbs']->addSimpleItem('Silex rocks', 'http://silex.sensiolabs.org/');
$app['breadcrumbs']->addSimpleItem('PHP', 'http://www.php.net');

```

The last item in your container is always printed as plain text without an tag. You can also add an breadcrumb item without any url. Then this breadcrumb item will also be printed as plain text.

```
$app['breadcrumbs']->addSimpleItem('Just some text');

```

### Old style deprecated

[](#old-style-deprecated)

```
$app['breadcrumbs']->addItem('Silex rocks', 'http://silex.sensiolabs.org/');
$app['breadcrumbs']->addItem('PHP', 'http://www.php.net');

```

The last item in your container is always printed as plain text without an tag. You can also add an breadcrumb item without any url. Then this breadcrumb item will also be printed as plain text.

```
$app['breadcrumbs']->addItem('Just some text');

```

### Named Routes

[](#named-routes)

You can also use named routes. This extension supports two types of named routes a simple and a complex one with parameters. Before you start to add a named route you will have to register (if not done already) the Silex UrlGeneratorServiceProvider.

```
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());

```

Then add this url generator to the breadcrumbs collection.

```
$app['breadcrumbs']->setUrlGenerator($app['url_generator']);

```

Now you're ready to go.

#### Simple named route

[](#simple-named-route)

If you got a simple route without any required parameters you can add this route to the breadcrumb collection as follows:

### New style

[](#new-style-1)

```
$app['breadcrumbs']->addRouteItem('A simple route', ['route' => 'simple_named_route']);

```

### Old style deprecated

[](#old-style-deprecated-1)

```
$app['breadcrumbs']->addItem('A simple route',array('route' => 'simple_named_route'));

```

#### Complex named route

[](#complex-named-route)

A complex named route is being added the same way as a simple named route. What needs to be done additionally is to pass an array with the required parameters as a second value to the array.

### New style

[](#new-style-2)

```
$app['breadcrumbs']->addRouteItem('A complex route', [
        'route' => 'complex_named_route',
        'params' => [
            'name' => "John",
            'id' => 3
        ]
    ]);

```

### Old style deprecated

[](#old-style-deprecated-2)

```
$app['breadcrumbs']->addItem('A complex route',array(
        'route' => 'complex_named_route',
        'params' => array(
            'name' => "John",
            'id' => 3
        )
    ));

```

#### Rendering breadcrumbs in twig

[](#rendering-breadcrumbs-in-twig)

In your Twig template you can render your breadcrumbs with this function:

```
{{renderBreadCrumbs()}}

```

The default template renders an unordered list. The last item has a css class called lastItem. You can override this template. Just copy the breadcrumbs.html.twig template from the vendor folder into your view path.

i18n Support
------------

[](#i18n-support)

Since version 1.1.0 this extension supports i18n. Each linkname has an optional translation filter which is only activated if you use the Translation Service Provider. For further information please refer to the Silex Documentation.

Optional configuration
----------------------

[](#optional-configuration)

The extension comes with a small configuration option which can be used optional. The default separator used for for the breadcrumbs is a &gt; sign. If you want to change it you can pass your own separator when registering the Twig extension:

```
$app['twig']->addExtension(new \nymo\Twig\Extension\BreadCrumbExtension($app),array("breadcrumbs.separator" => "::"));

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~140 days

Recently: every ~126 days

Total

12

Last Release

2901d ago

Major Versions

v1.2.0 → v2.0.02016-06-12

v2.1.0 → v3.0.02018-06-03

PHP version history (4 changes)1.0.x-devPHP &gt;=5.3.0

v2.0.0PHP &gt;=5.5.9

v2.0.1PHP &gt;=5.6

v3.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2171f50a86bbd5c63ba89b79c4ed3602db70974b07cea9204a53014603b5406a?d=identicon)[nymo](/maintainers/nymo)

---

Top Contributors

[![nymo](https://avatars.githubusercontent.com/u/884833?v=4)](https://github.com/nymo "nymo (56 commits)")[![mvanbaak](https://avatars.githubusercontent.com/u/1928231?v=4)](https://github.com/mvanbaak "mvanbaak (3 commits)")[![rusranx](https://avatars.githubusercontent.com/u/10733190?v=4)](https://github.com/rusranx "rusranx (1 commits)")

---

Tags

breadcrumbsphpsilexsilex-providertwig-extensiontwigextensionsilexbreadcrumbs

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nymo-silex-twig-breadcrumb-extension/health.svg)

```
[![Health](https://phpackages.com/badges/nymo-silex-twig-breadcrumb-extension/health.svg)](https://phpackages.com/packages/nymo-silex-twig-breadcrumb-extension)
```

###  Alternatives

[redant/twig-components

Define reusable components in Twig.

3819.8k1](/packages/redant-twig-components)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
