Twig

Php render templating.

Installation

composer require mediashare/kernel
1

Code

Create template

{# ./templates/index.html.twig #}
<h1>{{ name }}</h1>
1
2

Init Twig

<?php
// ./index.php
require 'vendor/autoload.php';
use Mediashare\Kernel\Kernel;

$kernel = new Kernel();
$kernel->run();

$twig = $kernel->get('Twig');
$twig->cache = __DIR__.'/var/cache/'; // or false (disable cache)
$twig->templates = __DIR__.'/templates';
$twig->run();
echo $twig->render('index.html.twig', ['name' => 'John Doe']);
1
2
3
4
5
6
7
8
9
10
11
12
13
Last Updated: 1/13/2020, 4:17:38 AM