TwigBundle Configuration ("twig")

Version: 2.6
Edit this page

Warning: You are browsing the documentation for Symfony 2.6, which is no longer maintained.

Read the updated version of this page for Symfony 5.3 (the current stable version).

TwigBundle Configuration ("twig")

  • YAML
  • XML
  • PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
twig:
    exception_controller:  twig.controller.exception:showAction

    form_themes:

        # Default:
        - form_div_layout.html.twig

        # Bootstrap:
        - bootstrap_3_layout.html.twig
        - bootstrap_3_horizontal_layout.html.twig

        # Example:
        - MyBundle::form.html.twig

    globals:

        # Examples:
        foo:                 "@bar"
        pi:                  3.14

        # Example options, but the easiest use is as seen above
        some_variable_name:
            # a service id that should be the value
            id:                   ~
            # set to service or leave blank
            type:                 ~
            value:                ~
    autoescape:                ~

    # The following were added in Symfony 2.3.
    # See http://twig.sensiolabs.org/doc/recipes.html#using-the-template-name-to-set-the-default-escaping-strategy
    autoescape_service:        ~ # Example: @my_service
    autoescape_service_method: ~ # use in combination with autoescape_service option
    base_template_class:       ~ # Example: Twig_Template
    cache:                     "%kernel.cache_dir%/twig"
    charset:                   "%kernel.charset%"
    debug:                     "%kernel.debug%"
    strict_variables:          ~
    auto_reload:               ~
    optimizations:             ~
    paths:
        "%kernel.root_dir%/../vendor/acme/foo-bar/templates": foo_bar

Caution

The twig.form (<twig:form /> tag for xml) configuration key has been deprecated and will be removed in 3.0. Instead, use the twig.form_themes option.

Configuration

exception_controller

type: string default: twig.controller.exception:showAction

This is the controller that is activated after an exception is thrown anywhere in your application. The default controller (ExceptionController) is what's responsible for rendering specific templates under different error conditions (see How to Customize Error Pages). Modifying this option is advanced. If you need to customize an error page you should use the previous link. If you need to perform some behavior on an exception, you should add a listener to the kernel.exception event (see The Dependency Injection Tags).

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.