Symfony Framework: Calling on other controllers from your TWIG views handy and efficient

In the newest versions of Symfony greater than 2.2 you can embed output from controller by calling it with this handy TWIG snippet:

Check out Sensio Lab’s documentation to learn more.

This is especially useful if you want to create a snippet that will deliver content independent of the controller you are calling the main content of the page — stuff around the periphery.  As long as you aren’t using any logic, this is an acceptable use of MVC and it decouples say content in a related widget on the page from the controller of the page’s main content.  This separation of concerns ensures the controller of the main content stays as lean and clean as possible!

Aaron Belchamber has written 247 articles

Leave a Reply

Your email address will not be published. Required fields are marked *