Finding out which version of the Twig you have installed in Symfony framework can be useful when solving bugs or installing packages. This tutorial shows how to check Twig version in Symfony.
We can use the Environment::VERSION
constant to determine Twig version.
test.php
<?php
use Twig\Environment;
require_once__DIR__.'/vendor/autoload.php';
echo Environment::VERSION;
This constant can be used in the template as follows:
templates/test/index.html.twig
{{ constant('Twig\\Environment::VERSION') }}