Skip to content

Commit 84c3c45

Browse files
committed
feature #19911 [FrameworkBundle] Add support for setting headers with TemplateContoller (Timherlaud)
This PR was merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Add support for setting headers with `TemplateContoller` fixes #19909 Commits ------- 5bcaf58 19909 [FrameworkBundle] Add support for setting headers
2 parents c223c31 + 5bcaf58 commit 84c3c45

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

templates.rst

+19
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,11 @@ provided by Symfony:
705705
site_name: 'ACME'
706706
theme: 'dark'
707707
708+
# optionally you can define HTTP headers to add to the response
709+
headers:
710+
Content-Type: 'text/html'
711+
foo: 'bar'
712+
708713
.. code-block:: xml
709714
710715
<!-- config/routes.xml -->
@@ -734,6 +739,11 @@ provided by Symfony:
734739
<default key="site_name">ACME</default>
735740
<default key="theme">dark</default>
736741
</default>
742+
743+
<!-- optionally you can define HTTP headers to add to the response -->
744+
<default key="headers">
745+
<default key="Content-Type">text/html</default>
746+
</default>
737747
</route>
738748
</routes>
739749
@@ -764,11 +774,20 @@ provided by Symfony:
764774
'context' => [
765775
'site_name' => 'ACME',
766776
'theme' => 'dark',
777+
],
778+
779+
// optionally you can define HTTP headers to add to the response
780+
'headers' => [
781+
'Content-Type' => 'text/html',
767782
]
768783
])
769784
;
770785
};
771786
787+
.. versionadded:: 7.2
788+
789+
The ``headers`` option was introduced in Symfony 7.2.
790+
772791
Checking if a Template Exists
773792
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
774793

0 commit comments

Comments
 (0)