PHP code example of litphp / view-twig

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

    

litphp / view-twig example snippets


$configuration += \Lit\View\Twig\TwigView::configuration(C::instance(\Twig\Loader\FilesystemLoader::class, [
    __DIR__ . '/templates',
]));

abstract class BaseAction extends BoltAbstractAction
{
    use \Lit\View\Twig\TwigViewBuilderTrait;

class HomeAction extends BaseAction
{
    protected function main(): ResponseInterface
    {
        return $this->twig('index.twig')->render(['name' => 'twig']);
    }