diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 526362f635c..344842212a2 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -54,6 +54,7 @@ TwigBundle Configuration ("twig") strict_variables: ~ auto_reload: ~ optimizations: ~ + default_path: '%kernel.project_dir%/templates' paths: '%kernel.project_dir%/vendor/acme/foo-bar/templates': foo_bar @@ -87,6 +88,7 @@ TwigBundle Configuration ("twig") debug="%kernel.debug%" strict-variables="false" optimizations="true" + default-path="%kernel.project_dir%/templates" > form_div_layout.html.twig form.html.twig @@ -136,6 +138,7 @@ TwigBundle Configuration ("twig") 'decimal_point' => ',', 'thousands_separator' => '.', ), + 'default_path' => '%kernel.project_dir%/templates', )); .. caution:: @@ -338,6 +341,16 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or disable these optimizations selectively, as explained in the Twig documentation about `the optimizer extension`_. +default_path +~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``'%kernel.project_dir%/templates'`` + +.. versionadded:: 3.4 + The ``default_path`` option was introduced in Symfony 3.4. + +The default directory where Symfony will look for Twig templates. + .. _config-twig-paths: paths @@ -346,9 +359,13 @@ paths **type**: ``array`` **default**: ``null`` This option defines the directories where Symfony will look for Twig templates -in addition to the default locations (``app/Resources/views/`` and the bundles' -``Resources/views/`` directories). This is useful to integrate the templates -included in some library or package used by your application. +in addition to the default locations. Symfony looks for the templates in the +following order: + +1. The directories defined in this option; +2. The ``Resources/views/`` directories of the bundles used in the application; +3. The ``src/Resources/views/`` directory of the application; +4. The directory defined in the ``default_path`` option. The values of the ``paths`` option are defined as ``key: value`` pairs where the ``value`` part can be ``null``. For example: