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)15310.0k↓54.6%54BSD-3-ClausePHPPHP ^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0CI failing

Since Nov 13Pushed 1mo 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 2d 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 and ping me in the issue/PR.

Laminas-MVC is in security-update, so the module will get no twig4 update or php85+ support.

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

63

—

FairBetter than 99% of packages

Maintenance70

Regular maintenance activity

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 72.1% 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

481d 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://avatars.githubusercontent.com/u/1885435?v=4)[Oliver](/maintainers/kokspflanze)[@kokspflanze](https://github.com/kokspflanze)

---

Top Contributors

[![kokspflanze](https://avatars.githubusercontent.com/u/1885435?v=4)](https://github.com/kokspflanze "kokspflanze (142 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.

18114.0k](/packages/oxcom-zend-twig)[symfony/ux-twig-component

Twig components for Symfony

22018.6M356](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1647.0M128](/packages/symfony-ux-live-component)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16126.1k1](/packages/symfony-ux-toolkit)[zfc-datagrid/zfc-datagrid

Laminas Module that provides a datagrid for different datasources and output formats

1224.9k](/packages/zfc-datagrid-zfc-datagrid)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

262.6k](/packages/mati365-ckeditor5-symfony)

PHPackages © 2026

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