Better Twig Support

By Fabien Potencier, on Sep 02, 2015

Even if Blackfire works for any PHP applications, we also try to make it easier to work with popular PHP libraries.

Twig being a widely used template engine in the PHP world, we looked at how to improve its support in Blackfire. To make rendering templates as fast as possible, Twig compiles templates into PHP files; at runtime, PHP executes the PHP cached file and never reads the original template again. That’s great from a performance perspective, but makes debugging with Blackfire slightly more difficult as template files refer to the cryptic cache file path instead of the original template path:

profile-without-names

Blackfire now automatically converts those cache paths back to the real template name to make it easier to spot which templates were rendered during code execution:

profile

As you can see on the screenshot, Blackfire does more than just displaying the template name you used in your code, it also tells you which block or macro was called.

To benefit from this improvement, don’t forget to upgrade your PHP probe.

Happy Twig profiling!

Fabien Potencier

Fabien Potencier is the CEO and founder of Blackfire.io. He founded the Symfony project in 2004 as he constantly looked for better ways to build websites. Fabien is also the creator of several other Open-Source projects, a writer, a blogger, a speaker at international conferences, and the happy father of two wonderful kids.