PHP code example of phpdot / template

1. Go to this page and download the library: Download phpdot/template 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/ */

    

phpdot / template example snippets


use PHPdot\Template\EngineFactory;
use PHPdot\Template\HtmlFormatter;
use PHPdot\Template\TemplateConfig;
use PHPdot\Template\View;

$config  = new TemplateConfig(paths: ['__main__' => [__DIR__ . '/views']]);
$factory = new EngineFactory($config, $manifest, $container);
$view    = new View($factory, new HtmlFormatter($config));

echo $view->render('hello.twig', ['name' => 'Omar']);

$view->render('mail/welcome.twig', ['user' => $user]);
$view->renderBlock('mail/welcome.twig', 'subject', ['user' => $user]);  // one block
$view->exists('admin/dashboard.twig');                                  // bool

$twig = $view->environment();   // escape hatch to the underlying Twig\Environment