$twig = new Twig_Environment(new Twig_Loader_Filesystem('templates/')); $twig->addExtension(new Twig_Extension_Debug()); $extension = $twig->getExtension('Debug');
$twig = new Twig_Environment(new Twig_Loader_Filesystem('templates/')); $extension = $twig->getExtension('My_Custom_Extension');In this example, we get an extension called 'My_Custom_Extension' from the Twig environment. This extension might be a custom extension we've added to the environment ourselves. The Twig templating engine is the package library that provides the Twig_Environment class and its methods, including getExtension().