2017 © Pedro Peláez
 

library twig

Integrate Twig with ZF2.

image

appt/twig

Integrate Twig with ZF2.

  • Wednesday, April 5, 2017
  • by alexshelkov
  • Repository
  • 2 Watchers
  • 2 Stars
  • 87 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Integrate Twig with ZF2., (*1)

Build Status, (*2)


Install

Using composer

Add following in your composer.json:, (*3)

{
    "require": {
        "appt/twig": "1.*"
    }
}

And enable module in your application.config.php:, (*4)

return array(
    'modules' => array(
        'ApptTwig',
    )
);


Usage

Configuration
Templates

ApptTwig support adding templates using common for Zend Framework 2 TemplateMapResolver and TemplatePathStack loaders., (*5)

return array(
    'appt' => array(
        'twig' => array(
            'default_template_suffix' => 'twg', // you can change file extension used by TemplatePathStack
            'template_path_stack' => array(
                'dir/1/',
                'dir/2/'
            ),
            'template_map' => array(
                'layout/layout' => 'dir/layout.twig',
                'error' => __DIR__ . 'dir/error.twig',
            ),
        ),
    ),
);
Twig options

You can change twig engine option in config:, (*6)

return array(
 'appt' => array(
        'twig' => array(
            'engine_options' => array(
                'debug' => true, // turn on debug mode
            )
        ),
    ),
);
Twig extensions

Also it is possible to add new twig extensions:, (*7)

return array(
    'appt' => array(
        'twig' => array(
            'extension_manager' => array(
                'factories' => array (
                    'ZendViewHelpers' => 'ApptTwig\Service\Extension\ZendViewHelpersFactory'
                )
            ),
        )
    )
);

All extensions must implement Twig_ExtensionInterface., (*8)

Provided services

ApptTwig provide following services:, (*9)

appt.twig.renderer -- renderer service compatible with PhpRenderer; appt.twig.renderer_strategy -- renderer strategy;
appt.twig.resolver -- resolver service extend Zend\View\Resolver\AggregateResolver and used for resolving templates; appt.twig.extension_manager -- used for managing twig extensions, it extend Zend\ServiceManager\AbstractPluginManager., (*10)

Rendering

When you setup resolvers in your config ApptTwig is ready for rendering view templates as it was regular PhpRenderer. All you need is create templates in your view directory., (*11)

The Versions

05/04 2017

dev-master

9999999-dev https://github.com/alexshelkov/ApptTwig

Integrate Twig with ZF2.

  Sources   Download

The Requires

 

by Alex Shelkovskiy

twig zend framework 2

18/03 2013

1.0.0

1.0.0.0 https://github.com/alexshelkov/ApptTwig

Integrate Twig with ZF2.

  Sources   Download

The Requires

 

by Alex Shelkovskiy

twig zend framework 2