mremi/templating-extra-bundle
mremi/templating-extra-bundle is a Symfony bundle that adds extra templating helpers and Twig extensions, making views cleaner and more reusable. It provides convenient utilities for common template tasks so you can reduce custom boilerplate in your application’s presentation layer.
Install via Composer and register the bundle in your dev/test environment only — it exists to feed the Symfony web profiler, so there's no reason to load it in production:
composer require --dev mremi/templating-extra-bundle
Modern Symfony (4+) — add to config/bundles.php:
return [
// ...
Mremi\TemplatingExtraBundle\MremiTemplatingExtraBundle::class => ['dev' => true, 'test' => true],
];
Legacy Symfony (2.x/3.x) — register in AppKernel::registerBundles():
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
$bundles[] = new Mremi\TemplatingExtraBundle\MremiTemplatingExtraBundle();
}
If the bundle exposes a config tree, drop it in config/packages/dev/mremi_templating_extra.yaml (or app/config/config_dev.yml on legacy) and enable it:
mremi_templating_extra:
enabled: true
Then load any page in dev, open the profiler (/_profiler), and pick a request. A Templates panel shows every template the templating layer rendered for that request — name, render time, and the parameters each render was invoked with.
First useful case: you have a slow page and the stock Twig panel tells you which templates are loaded, not which are rendered. Open the Templates panel, sort by count, and look for partials being rendered dozens of times inside a loop.
_sidebar.html.twig shows up forty times with identical parameters, a loop is re-including it. Hoist the include out of the loop, cache the fragment, or pass it once from the controller.{% embed %} chain for a page you didn't write.$profiler->getCollector('templating') (exact name varies by version), so you can pull the rendered list inside a test or a console command if you want to assert "this page renders no more than N templates."composer.json constraints before installing; on Symfony 5/6 the bundle config and the templating service it decorates have both moved, and you'll get either a "class not found" or an incompatible decoration error..phtml support the bundle advertises is dead weight. You're using it for the Twig side or not at all.render() path. Templates pulled in via {{ render(controller(...)) }} sub-requests, ESI, or anything bypassing the decorated service may not show up. If a template you know is on the page is missing, that's the first thing to suspect.bin/console debug:container --tag=data_collector./_profiler directly rather than relying on the toolbar for big pages.How can I help you explore Laravel packages today?