Silex - Twig_Error_Syntax: The function "path" does not exist
Hopefully this will help future viewers as many have posted this question without a solid answer, so here is one.
It is literally that you need UrlGeneratorServiceProvider()
registered
$app->register(new UrlGeneratorServiceProvider());
Also, as umpirsky mentions in the comments, you need symfony/twig-bridge
installed via composer.
You do not need to add your own function. You need both the TwigServiceProvider()
and the UrlGeneratorServiceProvider()
registered before loading your twig template. This isn't easily apparent from the documentation.