Recently I installed Twig2.0 via Composer for PHP7.2 and when running the code I'm getting these errors,
( ! ) Fatal error: Uncaught Error: Class 'Twig_Autoloader' not found in C:\wamp64\www\php-twig\example.php on line 4
( ! ) Error: Class 'Twig_Autoloader' not found in C:\wamp64\www\php-twig\example.php on line 4
I go through the issues in GitHub.
Here is my PHP code,
<?php
require 'vendor/autoload.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$options = array(
'name' => 'Sumithran',
);
$twig = new Twig_Environment($loader, $options);
And index.twig
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Twig test</title>
</head>
<body>
<h1>Hello world</h1>
<p>And hello {{ name }}</p>
</body>
</html>
How to solve this?