Skip to content

Commit 40c83db

Browse files
committed
[#1916] Adding back details that are new in 2.1 - partially taken from @dbu
1 parent 591f2dd commit 40c83db

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

cookbook/console/generating_urls.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,46 @@ what URL it should use when generating URLs.
1616
There are two ways of configuring the request context: at the application level
1717
and per Command.
1818

19+
Configuring the Request Context globally
20+
----------------------------------------
21+
22+
.. versionadded:: 2.1
23+
The host and scheme parameters are available since Symfony 2.1
24+
25+
To configure the Request Context - which is used by the URL Generator - you can
26+
redefine the parameters it uses as default values to change the default host
27+
(localhost) and scheme (http). Note that this does not impact URLs generated
28+
via normal web requests, since those will override the defaults.
29+
30+
.. configuration-block::
31+
32+
.. code-block:: yaml
33+
34+
# app/config/parameters.yml
35+
parameters:
36+
router.request_context.host: example.org
37+
router.request_context.scheme: https
38+
39+
.. code-block:: xml
40+
41+
<!-- app/config/parameters.xml -->
42+
<?xml version="1.0" encoding="UTF-8"?>
43+
44+
<container xmlns="http://symfony.com/schema/dic/services"
45+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
46+
47+
<parameters>
48+
<parameter key="router.request_context.host">example.org</parameter>
49+
<parameter key="router.request_context.scheme">https</parameter>
50+
</parameters>
51+
</container>
52+
53+
.. code-block:: php
54+
55+
// app/config/config_test.php
56+
$container->setParameter('router.request_context.host', 'example.org');
57+
$container->setParameter('router.request_context.scheme', 'https');
58+
1959
Configuring the Request Context per Command
2060
-------------------------------------------
2161

0 commit comments

Comments
 (0)