1. Go to this page and download the library: Download devtronic/twig-compose 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/ */
use Devtronic\TwigCompose\ComposeEnvironment;
$loader = new \Twig_Loader_Filesystem(''); // or whatever
$twig = new ComposeEnvironment($loader); // instead of Twig_Environment
$template = $twig->compose('base.html.twig', ['pluginA.html.twig', 'pluginB.html.twig']);
echo $template->render([]);
use Devtronic\TwigCompose\ComposeEnvironment;
$loader = new \Twig_Loader_Filesystem('/res/main-theme');
$twig = new ComposeEnvironment($loader);
$loader->addPath('/res/theme1', 'Theme1');
$loader->addPath('/res/theme2', 'Theme2');
// If autocompose is enabled, all registered paths will be checked.
// If a file with the the same name (e.g. base.html.twig) exists,
// it will be loaded & composed with the `base.html.twig` inside the main-theme folder
$twig->setAutoCompose(true);
$template = $twig->load('base.html.twig');
echo $template->render([]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.