PHPackages                             moss/twig-bridge - 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. moss/twig-bridge

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

moss/twig-bridge
================

moss-twig bridge

2.0(11y ago)0218MITPHPPHP &gt;=5.4

Since Nov 22Pushed 11y agoCompare

[ Source](https://github.com/mossphp/moss-twig-bridge)[ Packagist](https://packagist.org/packages/moss/twig-bridge)[ RSS](/packages/moss-twig-bridge/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

MOSS Twig bridge

[![Build Status](https://camo.githubusercontent.com/d94d65f394f8318cb06d0ee7763d47ebd5d1e2a806557162ba762c64cdcbe154/68747470733a2f2f7472617669732d63692e6f72672f6d6f73737068702f6d6f73732d747769672d6272696467652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mossphp/moss-twig-bridge)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fefb9bfac3416e3783823e79ea04c1a99aac121863e697da3c372e82023ccf55/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6f73737068702f6d6f73732d747769672d6272696467652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mossphp/moss-twig-bridge/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/5d2008b6c6c927a3c96e708729a0ec9df54060bc4621e34702d9218c652710a2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6f73737068702f6d6f73732d747769672d6272696467652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mossphp/moss-twig-bridge/?branch=master)

Adds Twig as template engine with additional functionalities:

**resource** - simplifies usage of bundle resources, creates symlinks to bundle resources/assets (or if unable, copies them, this can be forced too).

```

```

Will create symlink to `./src/app/front/resource/js/jquery.min.js` from `./web/resource/app/front/js/jquery.min.js`. Same applies to other files, as long as they are placed in bundles resource directory.

**url** - convenient router wrapper - `{{ url('routeName', { here: "be", some: 'attributes' }) }}`.

**translation** - translation module, merging functionality from Twigs i18n extension and more sophisticated Pluralization from `Sf2 Translator`.

```
{% trans with {'%name%': 'Michal'} "Hello %name%" %}

{% trans with {'%name%': 'Michal'} %}Hello %name%{% endtrans %}

{% transchoice count with {'%name%': 'Michal'} %}
{0} %name%, there are no apples|{1} %name%, there is one apple|]1,Inf] %name%, there are %count% apples
{% endtranschoice %}
```

`with {....}` is optional and can be ommited

**formatting** - for formatting values to their country specific formats

```
{{ $value|number }} - formats $value as number
{{ $value|currency }} - formats $value as currency
{{ $value|time }} - formats $value (which must be a \DateTime object) as time
{{ $value|date }} - formats $value (\DateTime object) as date
{{ $value|dateTime }} - formats $value (\DateTime object) as date time
```

And of course, normal Twig extensions are also included.

To use it, just replace default `view` component in bootstrap with:

```
	'view' => array(
	        'closure' => function (\Moss\Container\Container $container) {
	                $options = array(
	                    'debug' => true,
	                    'auto_reload' => true,
	                    'strict_variables' => false,
	                    'cache' => '../compile/'
	                );

	                $twig = new Twig_Environment(new Moss\Bridge\Loader\File(), $options);
	                $twig->setExtensions(
	                    array(
	                        new Moss\Bridge\Extension\Resource(),
	                        new Moss\Bridge\Extension\Url($container->get('router')),
	                        new Moss\Bridge\Extension\Trans(),
	                        new Twig_Extensions_Extension_Text(),
	                    )
	                );

	                $view = new \Moss\Bridge\View\View($twig);
	                $view
	                    ->set('request', $container->get('request'))
	                    ->set('config', $container->get('config'));

	                return $view;
	            }
	    )
```

For licence details see LICENCE.md

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~63 days

Total

3

Last Release

4064d ago

Major Versions

1.1.0 → 2.02015-03-29

PHP version history (2 changes)1.0PHP &gt;=5.3.4

2.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8addaf28c1a25afd6006377779228ee980528e4ca23793a4ab8bc426dda5018b?d=identicon)[potfur](/maintainers/potfur)

---

Top Contributors

[![potfur](https://avatars.githubusercontent.com/u/1244857?v=4)](https://github.com/potfur "potfur (62 commits)")

---

Tags

twigBridgemossphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/moss-twig-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/moss-twig-bridge/health.svg)](https://phpackages.com/packages/moss-twig-bridge)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36663.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

21946.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

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