2017 © Pedro Peláez
 

library zfc-twig

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

image

kokspflanze/zfc-twig

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

  • Tuesday, April 3, 2018
  • by kokspflanze
  • Repository
  • 2 Watchers
  • 6 Stars
  • 20,796 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 61 Forks
  • 1 Open issues
  • 35 Versions
  • 20 % Grown

The README.md

ZfcTwig Module for Laminas/Zend Framework Build Status

ZfcTwig is a module that integrates the Twig templating engine with Laminas / Zend Framework., (*1)

Information

this is a fork of 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 or open a PullRequest., (*2)

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

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 class., (*3)

Documentation

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., (*4)

// 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

By default, ZfcTwig uses a Twig\Loader\ChainLoader so that loaders can be chained together. A convenient default is setup using a filesystem loader 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., (*5)

// 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 is supported through the ZfcTwig\Twig\FallbackFunction function., (*6)

{# 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

Example .twig files for the skeleton application can be found in the examples folder., (*7)

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., (*8)

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., (*9)

The Versions

03/04 2018
30/03 2018

dev-develop

dev-develop https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig zf2 module zf

30/03 2018
05/11 2017

dev-release/1.4

dev-release/1.4 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

05/11 2017

1.4.3

1.4.3.0 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

20/08 2017
20/08 2017
30/05 2017

1.4.2

1.4.2.0 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

26/05 2017
04/12 2016

1.4.1

1.4.1.0 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

07/11 2016

1.4.0

1.4.0.0 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

14/10 2016

1.3.2

1.3.2.0 https://github.com/kokspflanze/ZfcTwig/

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

twig module zf

08/08 2016

1.3.1

1.3.1.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

08/08 2016

dev-prepare_zf3

dev-prepare_zf3 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

08/08 2016

dev-travis_test

dev-travis_test http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

19/07 2016

1.3.0

1.3.0.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

29/04 2014

1.2.2

1.2.2.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

05/03 2014

1.2.1

1.2.1.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

24/01 2014

1.2

1.2.0.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

The Development Requires

twig zf2 module

24/06 2013

1.1.5

1.1.5.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

20/06 2013

1.1.4

1.1.4.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

10/06 2013

1.1.3

1.1.3.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

19/04 2013

1.1.2

1.1.2.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

18/04 2013

1.1.1

1.1.1.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

16/04 2013

1.1.0

1.1.0.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

08/02 2013

1.0.3

1.0.3.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

16/01 2013

1.0.2

1.0.2.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

11/12 2012

1.0.1

1.0.1.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

29/11 2012

1.0

1.0.0.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module

13/11 2012

0.1

0.1.0.0 http://www.github.com/ZF-Commons/ZfcTwig/

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

  Sources   Download

The Requires

 

twig zf2 module