@@ -29,13 +29,17 @@ When developing a Symfony application, your responsibility as a developer
29
29
is to write the code that maps the user's *request * (e.g. ``http://localhost:8000/ ``)
30
30
to the *resource * associated with it (the ``Homepage `` HTML page).
31
31
32
- The code to execute is defined in **actions ** and **controllers **. The mapping
33
- between user's requests and that code is defined via the **routing ** configuration.
34
- And the contents displayed in the browser are usually rendered using **templates **.
32
+ The code to execute is defined as methods of PHP classes. The methods are
33
+ called **actions ** and the classes **controllers **, but in practice most
34
+ developers use **controllers ** to refer to both of them. The mapping between
35
+ user's requests and that code is defined via the **routing ** configuration.
36
+ And the contents displayed in the browser are usually rendered using
37
+ **templates **.
38
+
39
+ When you go to ``http://localhost:8000/app/example ``, Symfony will execute
40
+ the controller in ``src/AppBundle/Controller/DefaultController.php `` and
41
+ render the ``app/Resources/views/default/index.html.twig `` template.
35
42
36
- When you browsed ``http://localhost:8000/app/example `` earlier, Symfony executed
37
- the controller defined in the ``src/AppBundle/Controller/DefaultController.php ``
38
- file and rendered the ``app/Resources/views/default/index.html.twig `` template.
39
43
In the following sections you'll learn in detail the inner workings of Symfony
40
44
controllers, routes and templates.
41
45
@@ -69,7 +73,7 @@ is called ``Default`` and the PHP class is called ``DefaultController``.
69
73
The methods defined in a controller are called **actions **, they are usually
70
74
associated with one URL of the application and their names are suffixed
71
75
with ``Action ``. In this example, the ``Default `` controller has only one
72
- action called ``index `` and defined in the ``indexAction `` method.
76
+ action called ``index `` and defined in the ``indexAction() `` method.
73
77
74
78
Actions are usually very short - around 10-15 lines of code - because they
75
79
just call other parts of the application to get or generate the needed
@@ -85,7 +89,7 @@ Routing
85
89
Symfony routes each request to the action that handles it by matching the
86
90
requested URL against the paths configured by the application. Open again
87
91
the ``src/AppBundle/Controller/DefaultController.php `` file and take a look
88
- at the three lines of code above the ``indexAction `` method::
92
+ at the three lines of code above the ``indexAction() `` method::
89
93
90
94
// src/AppBundle/Controller/DefaultController.php
91
95
namespace AppBundle\Controller;
@@ -138,7 +142,8 @@ The only content of the ``index`` action is this PHP instruction::
138
142
139
143
The ``$this->render() `` method is a convenient shortcut to render a template.
140
144
Symfony provides some useful shortcuts to any controller extending from
141
- the ``Controller `` class.
145
+ the base Symfony :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ Controller `
146
+ class.
142
147
143
148
By default, application templates are stored in the ``app/Resources/views/ ``
144
149
directory. Therefore, the ``default/index.html.twig `` template corresponds
@@ -194,7 +199,7 @@ environments**.
194
199
What is an Environment?
195
200
~~~~~~~~~~~~~~~~~~~~~~~
196
201
197
- An :term: `Environment ` represents a group of configurations that's used
202
+ An :term: `environment ` represents a group of configurations that's used
198
203
to run your application. Symfony defines two environments by default: ``dev ``
199
204
(suited for when developing the application locally) and ``prod `` (optimized
200
205
for when executing the application on production).
@@ -235,7 +240,7 @@ In this example, the ``config_dev.yml`` configuration file imports the common
235
240
with its own options.
236
241
237
242
For more details on environments, see
238
- " :ref: `Environments & Front Controllers <page-creation-environments >`" article .
243
+ :ref: `the " Environments" section <page-creation-environments >` of the book .
239
244
240
245
Final Thoughts
241
246
--------------
@@ -246,6 +251,4 @@ how Symfony makes it really easy to implement web sites better and faster.
246
251
If you are eager to learn more about Symfony, dive into the next section:
247
252
":doc: `The View <the_view >`".
248
253
249
- .. _Composer : https://getcomposer.org/
250
- .. _executable installer : https://getcomposer.org/download
251
- .. _Twig : http://twig.sensiolabs.org/
254
+ .. _`Twig` : http://twig.sensiolabs.org/
0 commit comments