To give you a runnable sample:
Install Twig in empty project:
composer require "twig/twig:^3.0"
Create the following "test.php" file:
<?php
require_once('vendor/autoload.php');
$loader = new \Twig\Loader\FilesystemLoader('./templates');
$twig = new \Twig\Environment($loader);
echo $twig->render('demo.twig', ['name' => 'Fabien']);
Create the view:
mkdir templates
cd templates
echo "Hello, {{ name }}!" > demo.twig
Run the demo:
cd ..
php test.php