PHP code example of stratify / twig-module

1. Go to this page and download the library: Download stratify/twig-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stratify / twig-module example snippets


function (Twig_Environment $twig) {
    return $twig->render('home.twig');
}

    'twig.paths' => add([
        __DIR__.'/../views',
    ]),
    

    'twig.paths' => add([
        'blog' => __DIR__.'/../views',
    ]),
    

    'twig.options' => add([
        'strict_variables' => true,
    ]),
    

    'twig.globals' => add([
        'appName' => 'My super project',
        'debug' => get('debug'), // container parameters can be injected too
    ]),
    

    'twig.extensions' => add([
        get(Twig_Extension_Profiler::class),
        get(My\Custom\TwigExtension::class),
    ]),
    

'twig.options' => [
    'cache' => /* cache directory */,
],

'twig.options' => [
    'debug' => true,
    'cache' => false,
    'strict_variables' => true,
],