PHP code example of sarah-systems / ci4twig

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

    

sarah-systems / ci4twig example snippets




\CI4Twig\view('template.html.twig');

use function CI4Twig\view as view;
view('template.html.twig');

\CI4Twig\view('template');

$data = [ 'apple' , 'banana' , 'lemon' ];
\CI4Twig\view('template',$data);

use CI4Twig\Config\Services;

$time = date('Y-m-d H:i:s');
$twig = Services::twig();
$twig->Environment->addGlobal('time',$time);
$twig->Environment->display('template.html.twig');