PHP code example of cedricziel / twig-loader-flysystem

1. Go to this page and download the library: Download cedricziel/twig-loader-flysystem 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/ */

    

cedricziel / twig-loader-flysystem example snippets


$localAdapter = new League\Flysystem\Adapter\Local(__DIR__);
$filesystem = League\Flysystem\Filesystem($localAdapter);

$loader = new CedricZiel\TwigLoaderFlysystem\FlysystemLoader($filesystem);
$twig = new \Twig_Environment($loader);

$template = $twig->loadTemplate('index.html.twig');
$content = $template->render(array('the' => 'variables', 'go' => 'here'));

$localAdapter = new League\Flysystem\Adapter\Local(__DIR__);
$filesystem = League\Flysystem\Filesystem($localAdapter);

$loader = new CedricZiel\TwigLoaderFlysystem\FlysystemLoader($filesystem, 'templates');
$twig = new \Twig_Environment($loader);

// this will load 'templates/index.html.twig' from the current flysystem filesystem
$template = $twig->loadTemplate('index.html.twig');
$content = $template->render(array('the' => 'variables', 'go' => 'here'));