PHPackages                             kokspflanze/zfc-twig - 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. kokspflanze/zfc-twig

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

kokspflanze/zfc-twig
====================

Laminas/Zend Framework Module that provides a Twig rendering strategy and extensions to render actions or trigger events from your templates

4.2.1(1y ago)15299.3k↓20.7%54BSD-3-ClausePHPPHP ^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0CI failing

Since Nov 13Pushed 1y ago3 watchersCompare

[ Source](https://github.com/kokspflanze/ZfcTwig)[ Packagist](https://packagist.org/packages/kokspflanze/zfc-twig)[ Docs](https://github.com/kokspflanze/ZfcTwig/)[ RSS](/packages/kokspflanze-zfc-twig/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (41)Used By (4)

ZfcTwig Module for Laminas/Zend Framework [![Build Status](https://camo.githubusercontent.com/23ec3ba49c8274b03c384df24d93e30ec59b2f37a07f53f7451474b3979bf10f/68747470733a2f2f7472617669732d63692e6f72672f6b6f6b7370666c616e7a652f5a6663547769672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kokspflanze/ZfcTwig)
==================================================================================================================================================================================================================================================================================================================================

[](#zfctwig-module-for-laminaszend-framework-)

ZfcTwig is a module that integrates the [Twig](http://twig.sensiolabs.org) templating engine with [Laminas](https://getlaminas.org/) / [Zend Framework](https://framework.zend.com).

Information
-----------

[](#information)

this is a fork of [ZF-Commons/ZfcTwig](https://github.com/ZF-Commons/ZfcTwig). I added ZF3 support, so the module works with Laminas / Zend Framework 2 and 3. If you found a bug, please report it, just pm me in [gitter](https://gitter.im/kokspflanze) or open a PullRequest.

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

[](#installation)

1. Add `"kokspflanze/zfc-twig": "dev-master"` to your `composer.json` file and run `php composer.phar update`.
2. Add `ZfcTwig` to your `config/application.config.php` file under the `modules` key.

Configuration
-------------

[](#configuration)

ZfcTwig has sane defaults out of the box but offers optional configuration via the `zfctwig` configuration key. For detailed information on all available options see the [module config file](https://github.com/kokspflanze/ZfcTwig/blob/master/config/module.config.php)class.

Documentation
-------------

[](#documentation)

### Setting up Twig extensions

[](#setting-up-twig-extensions)

Extensions can be registered with Twig by adding the FQCN to the `extensions` configuration key which is exactly how the ZfcTwig extension is registered.

```
// in module configuration or autoload override
return [
    'zfctwig' => [
        'extensions' => [
            // an extension that uses no key
            'My\Custom\Extension',

            // an extension with a key so that you can remove it from another module
            'my_custom_extension' => 'My\Custom\Extension'
        ]
    ]
];
```

### Configuring Twig loaders

[](#configuring-twig-loaders)

By default, `ZfcTwig` uses a `Twig\Loader\ChainLoader` so that loaders can be chained together. A convenient default is setup using a [filesystem loader](https://github.com/kokspflanze/ZfcTwig/blob/master/config/module.config.php#L31) with the path set to `module/Application/view` which should work out of the box for most instances. If you wish to add additional loaders to the chain you can register them by adding the service manager alias to the `loaders` configuration key.

```
// in module configuration or autoload override
return [
    'zfctwig' => [
        'loader_chain' => [
            'MyTwigFilesystemLoader'
        ]
    ]
];

// in some module
public function getServiceConfiguration()
{
    return [
        'factories' => [
            'MyTwigFilesystemLoader' => function($sm) {
                return new \Twig\Loader\FilesystemLoader('my/custom/twig/path');
            }
        ]
    ];
}
```

### Using ZF View Helpers

[](#using-zf-view-helpers)

Using ZF view helpers is supported through the [ZfcTwig\\Twig\\FallbackFunction](https://github.com/kokspflanze/ZfcTwig/blob/master/src/Twig/FallbackFunction.php)function.

```
{# Simple view helper echo #}
{{ doctype() }}

{# Echo with additional methods #}
{{ headTitle('My Company').setSeparator('-') }}

{# Using a view helper without an echo #}
{% do headTitle().setSeparator('-') %}

{# Combining view helpers #}
{% set url = ( url('my/custom/route') ) %}
```

Examples
========

[](#examples)

Example .twig files for the skeleton application can be found in the [examples](https://github.com/kokspflanze/ZfcTwig/tree/master/examples)folder.

Gotchas
-------

[](#gotchas)

ZF does not support multiple renderers with view helpers very well. As a workaround, ZfcTwig registers its own `HelperPluginManager` that extends the default `Laminas\View\HelperPluginManager` and adds the default as a peering manager. This let's ZfcTwig register its own renderer with view helpers that require it and fallback to the default manager for view helpers that do not require one.

As a caveat, you *must* register view helpers that require a renderer with ZfcTwig. An example can be seen in `config/module.config.php` where the HelperConfig for the default navigation helpers is registered with ZfcTwig.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance44

Moderate activity, may be stable

Popularity44

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 71.9% 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 ~121 days

Recently: every ~354 days

Total

38

Last Release

435d ago

Major Versions

1.4.1 → 2.02017-01-16

1.4.3 → 2.1.12017-11-05

1.4.4 → 2.3.12019-04-16

2.3.2 → 3.0.02019-11-20

3.0.0 → 4.0.02020-01-07

PHP version history (11 changes)0.1PHP &gt;=5.3.3

1.3.0PHP &gt;=5.5

1.4.0PHP ^5.5 || ^7.0

2.0PHP ^7.0

2.3.0PHP ^7.1

3.0.0PHP ^7.2.9

4.0.1PHP ^7.3 || ^8.0

4.1.0PHP ^7.3 || ~8.0.0 || ~8.1.0

4.1.1PHP ^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0

4.2.0PHP ^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

4.2.1PHP ^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

### Community

Maintainers

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

---

Top Contributors

[![kokspflanze](https://avatars.githubusercontent.com/u/1885435?v=4)](https://github.com/kokspflanze "kokspflanze (141 commits)")[![cosmin-harangus](https://avatars.githubusercontent.com/u/381639?v=4)](https://github.com/cosmin-harangus "cosmin-harangus (17 commits)")[![spiffyjr](https://avatars.githubusercontent.com/u/2760734?v=4)](https://github.com/spiffyjr "spiffyjr (11 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (4 commits)")[![bakura10](https://avatars.githubusercontent.com/u/1198915?v=4)](https://github.com/bakura10 "bakura10 (3 commits)")[![EvanDotPro](https://avatars.githubusercontent.com/u/5607?v=4)](https://github.com/EvanDotPro "EvanDotPro (3 commits)")[![saadhre](https://avatars.githubusercontent.com/u/3045021?v=4)](https://github.com/saadhre "saadhre (3 commits)")[![xoob](https://avatars.githubusercontent.com/u/53278?v=4)](https://github.com/xoob "xoob (2 commits)")[![nikolay-kozlov](https://avatars.githubusercontent.com/u/6401099?v=4)](https://github.com/nikolay-kozlov "nikolay-kozlov (2 commits)")[![0legKolomiets](https://avatars.githubusercontent.com/u/5287629?v=4)](https://github.com/0legKolomiets "0legKolomiets (2 commits)")[![kusmierz](https://avatars.githubusercontent.com/u/404344?v=4)](https://github.com/kusmierz "kusmierz (1 commits)")[![alexdenvir](https://avatars.githubusercontent.com/u/1412074?v=4)](https://github.com/alexdenvir "alexdenvir (1 commits)")[![rmasters](https://avatars.githubusercontent.com/u/34284?v=4)](https://github.com/rmasters "rmasters (1 commits)")[![halaxa](https://avatars.githubusercontent.com/u/2226505?v=4)](https://github.com/halaxa "halaxa (1 commits)")[![Saeven](https://avatars.githubusercontent.com/u/887224?v=4)](https://github.com/Saeven "Saeven (1 commits)")[![exptom](https://avatars.githubusercontent.com/u/4302032?v=4)](https://github.com/exptom "exptom (1 commits)")[![jonmorrison99](https://avatars.githubusercontent.com/u/1491156?v=4)](https://github.com/jonmorrison99 "jonmorrison99 (1 commits)")[![hikaru-shindo](https://avatars.githubusercontent.com/u/524290?v=4)](https://github.com/hikaru-shindo "hikaru-shindo (1 commits)")

---

Tags

laminastwigzfmodulezf3twig2twig3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kokspflanze-zfc-twig/health.svg)

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

###  Alternatives

[oxcom/zend-twig

ZendTwig is a module that integrates the Twig template engine with Zend Framework 3.

19109.7k](/packages/oxcom-zend-twig)[twig/extra-bundle

A Symfony bundle for extra Twig extensions

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

A Twig extension for Intl

36763.2M221](/packages/twig-intl-extra)[twig/string-extra

A Twig extension for Symfony String

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

A Twig extension to allow inlining CSS

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

Twig components for Symfony

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

PHPackages © 2026

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