@@ -16,6 +16,46 @@ what URL it should use when generating URLs.
16
16
There are two ways of configuring the request context: at the application level
17
17
and per Command.
18
18
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
+
19
59
Configuring the Request Context per Command
20
60
-------------------------------------------
21
61
0 commit comments