How to add a twig extension from a library in Symfony?

  php, symfony, twig

I would like to use a twig extension in my project, like this:

$twig->addExtension(new SomeLibraryExampleTwigExtension());
$someLibInstance->setViewProvider(new TwigViewProvider($twig));

I tried to find out, how to add twig extensions, but all I’ve found was about creating my own extension, not about adding an existing one.

Source: Symfony Questions