Skip to content

Commit 49a586a

Browse files
committed
Merge branch 'dbu-patch-1'
2 parents 414c0bb + dc3640c commit 49a586a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cookbook/console/generating_urls.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ Configuring the Request Context globally
2222
.. versionadded:: 2.1
2323
The ``host`` and ``scheme`` parameters are available since Symfony 2.1
2424

25+
.. versionadded: 2.2
26+
27+
The base_url parameter is available since Symfony 2.2
28+
2529
To configure the Request Context - which is used by the URL Generator - you can
2630
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.
31+
(localhost) and scheme (http). Starting with Symfony 2.2 you can also configure
32+
the base path if Symfony is not running in the root directory.
33+
34+
Note that this does not impact URLs generated via normal web requests, since those
35+
will override the defaults.
2936

3037
.. configuration-block::
3138

@@ -35,6 +42,7 @@ via normal web requests, since those will override the defaults.
3542
parameters:
3643
router.request_context.host: example.org
3744
router.request_context.scheme: https
45+
router.request_context.base_url: my/path
3846
3947
.. code-block:: xml
4048
@@ -47,6 +55,7 @@ via normal web requests, since those will override the defaults.
4755
<parameters>
4856
<parameter key="router.request_context.host">example.org</parameter>
4957
<parameter key="router.request_context.scheme">https</parameter>
58+
<parameter key="router.request_context.base_url">my/path</parameter>
5059
</parameters>
5160
</container>
5261
@@ -55,6 +64,7 @@ via normal web requests, since those will override the defaults.
5564
// app/config/config_test.php
5665
$container->setParameter('router.request_context.host', 'example.org');
5766
$container->setParameter('router.request_context.scheme', 'https');
67+
$container->setParameter('router.request_context.base_url', 'my/path');
5868
5969
Configuring the Request Context per Command
6070
-------------------------------------------
@@ -72,6 +82,7 @@ service and override its settings::
7282
$context = $this->getContainer()->get('router')->getContext();
7383
$context->setHost('example.com');
7484
$context->setScheme('https');
85+
$context->setBaseUrl('my/path');
7586

7687
// ... your code here
7788
}

0 commit comments

Comments
 (0)