Skip to content

Commit 396ef90

Browse files
committed
[#1778] Adding index entries and tweaks via @wouterj for the new Command URL generation cookbook entry
1 parent dfec0ad commit 396ef90

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

cookbook/console/generating_urls.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
.. index::
22
single: Console; Generating URLs
33

4-
How to generate URLs with a custom host in Console Commands
4+
How to generate URLs with a custom Host in Console Commands
55
===========================================================
66

7-
The command line context does not know about your VirtualHost or domain name,
8-
therefore if you generate absolute URLs within a Console Command you generally
9-
end up with something like ``http://localhost/foo/bar`` which is not very
10-
useful.
7+
Unfortunately, the command line context does not know about your VirtualHost
8+
or domain name. This means that if if you generate absolute URLs within a
9+
Console Command you'll probably end up with something like ``http://localhost/foo/bar``
10+
which is not very useful.
1111

12-
There are two ways of configuring the request context, at the application level
12+
To fix this, you need to configure the "request context", which is a fancy
13+
way of saying that you need to configure your environment so that it knows
14+
what URL it should use when generating URLs.
15+
16+
There are two ways of configuring the request context: at the application level
1317
and per Command.
1418

1519
Configuring the Request Context globally
@@ -31,8 +35,6 @@ via normal web requests, since those will override the defaults.
3135
3236
.. code-block:: xml
3337
34-
<!-- app/config/parameters.xml -->
35-
3638
<?xml version="1.0" encoding="UTF-8"?>
3739
3840
<container xmlns="http://symfony.com/schema/dic/services"
@@ -54,11 +56,11 @@ Configuring the Request Context per Command
5456
-------------------------------------------
5557

5658
To change it only in one command you can simply fetch the Request Context
57-
service and override its settings:
58-
59-
.. code-block:: php
59+
service and override its settings::
6060

6161
// src/Acme/DemoBundle/Command/DemoCommand.php
62+
// ...
63+
6264
class DemoCommand extends ContainerAwareCommand
6365
{
6466
protected function execute(InputInterface $input, OutputInterface $output)
@@ -67,7 +69,7 @@ service and override its settings:
6769
$context->setHost('example.com');
6870
$context->setScheme('https');
6971

70-
// your code here
72+
// ... your code here
7173
}
7274
}
7375

cookbook/console/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Console
66

77
console_command
88
usage
9+
generating_urls

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
* :doc:`/cookbook/console/console_command`
3030
* :doc:`/cookbook/console/usage`
31+
* :doc:`/cookbook/console/generating_urls`
3132

3233
* :doc:`/cookbook/controller/index`
3334

0 commit comments

Comments
 (0)