Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Symfony Plugin to enable Twig usage in templates.
tree: 547616dbec

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.



This plugin tries to integrate the Twig into Symfony

TextMate tick

To get support for Syntax highligting when coding in the twig "language" it is desireable to install Django HTML syntax highlighting support, which will highlight both the html and the twig code. There will might be some glitches though.


This is a HUGE project for one man, so if YOU want to contribute in any dont hesitate to fork me or open an issue or contact med at yep [at] The first really big thing that needs help is porting the Core and Standard helpers for Symfony to Twig Extensions either as tags or filters.


Create a file named module.yml in project/config or app/config dir with the following content.

    view_class: sfTwig
    partial_view_class: sfTwig

This will enable the sfTwigView class to be used when rendering templates.


Usage is simple, this plugin replaces sfPHPView and therefor the template file extension have changed into .html. But because this is not exactly the same as sfPHPView and Twig dosent allow function calling from within the templates none of the normal helpers will work until they have been converted to Twig Extensions.

To Generate the port of symfony helpers into Twig Extensions do the following:

cd ./plugins/sfTwigPlugin ./ /path/to/syfmony/lib/helper/

This script will scan the symfony helper folder (Or any folder with files ending with Helper.php) and with create Twig Extensions based on them inside the ./lib/extensions folder of the plugin. sed, awk & php must be in the path.

Then in order to use the UrlHelper with Twig you can do:

$twig->addExtension(new Url_Twig_Extension());

Something went wrong with that request. Please try again.