From 3503f988aaebf49242414b7041cffee761204cec Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 12 Nov 2012 10:38:33 +0100 Subject: [PATCH 1/2] add router.request_context.base_url to cookbook entry --- cookbook/console/generating_urls.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cookbook/console/generating_urls.rst b/cookbook/console/generating_urls.rst index 1e3ef5ee0dc..486a809fae1 100644 --- a/cookbook/console/generating_urls.rst +++ b/cookbook/console/generating_urls.rst @@ -21,8 +21,11 @@ Configuring the Request Context globally To configure the Request Context - which is used by the URL Generator - you can redefine the parameters it uses as default values to change the default host -(localhost) and scheme (http). Note that this does not impact URLs generated -via normal web requests, since those will override the defaults. +(localhost) and scheme (http). Starting with Symfony 2.2 you can also configure +the base path if Symfony is not running in the root directory. + +Note that this does not impact URLs generated via normal web requests, since those +will override the defaults. .. configuration-block:: @@ -32,6 +35,7 @@ via normal web requests, since those will override the defaults. parameters: router.request_context.host: example.org router.request_context.scheme: https + router.request_context.base_url: my/path .. code-block:: xml @@ -44,6 +48,7 @@ via normal web requests, since those will override the defaults. example.org https + my/path @@ -52,6 +57,7 @@ via normal web requests, since those will override the defaults. // app/config/config_test.php $container->setParameter('router.request_context.host', 'example.org'); $container->setParameter('router.request_context.scheme', 'https'); + $container->setParameter('router.request_context.base_url', 'my/path'); Configuring the Request Context per Command ------------------------------------------- @@ -69,6 +75,7 @@ service and override its settings:: $context = $this->getContainer()->get('router')->getContext(); $context->setHost('example.com'); $context->setScheme('https'); + $context->setBaseUrl('my/path'); // ... your code here } From 7069e85f9dba50db0a616ebfcbcfaab637379b93 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Tue, 13 Nov 2012 09:02:45 +0100 Subject: [PATCH 2/2] add versionadded notes --- cookbook/console/generating_urls.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cookbook/console/generating_urls.rst b/cookbook/console/generating_urls.rst index 486a809fae1..a441ab8c89b 100644 --- a/cookbook/console/generating_urls.rst +++ b/cookbook/console/generating_urls.rst @@ -19,6 +19,14 @@ and per Command. Configuring the Request Context globally ---------------------------------------- +.. versionadded: 2.1 + + The host and scheme parameters are available since Symfony 2.1 + +.. versionadded: 2.2 + + The base_url parameter is available since Symfony 2.2 + To configure the Request Context - which is used by the URL Generator - you can redefine the parameters it uses as default values to change the default host (localhost) and scheme (http). Starting with Symfony 2.2 you can also configure