@@ -49,13 +49,13 @@ should now have a ``sandbox/`` directory::
49
49
Checking the Configuration
50
50
--------------------------
51
51
52
- Symfony2 comes with a visual server configuration tester to help avoid some
52
+ Symfony2 comes with a visual server configuration tester to help avoid some
53
53
headaches that come from web server or PHP misconfiguration. Use the following
54
54
url to see the diagnostics for your server:
55
55
56
56
http://localhost/sandbox/web/check.php
57
57
58
- Read the script output carefully and correct any oustanding issues.
58
+ Read the script output carefully and correct any oustanding issues.
59
59
60
60
Now you can request your first "real" Symfony2 webpage:
61
61
@@ -92,8 +92,8 @@ Fabien!``).
92
92
Configuration
93
93
~~~~~~~~~~~~~
94
94
95
- Symfony2 configuration files can be written in PHP, XML or `YAML `_. The
96
- different types are compatible and may be used interchangeably within an
95
+ Symfony2 configuration files can be written in PHP, XML or `YAML `_. The
96
+ different types are compatible and may be used interchangeably within an
97
97
application.
98
98
99
99
.. tip ::
@@ -154,16 +154,17 @@ are a few examples of the routing configuration file for our application:
154
154
155
155
return $collection;
156
156
157
- The first few lines of the routing configuration file define the code that is
158
- executed when the user requests the resource specified by the pattern "``/ ``" (i.e. the homepage).
159
- Here, it executes the "``index ``" method of the "``Default ``" controller inside the "``FrameworkBundle ``"
157
+ The first few lines of the routing configuration file define the code that
158
+ is executed when the user requests the resource specified by the pattern
159
+ "``/ ``" (i.e. the homepage). Here, it executes the ``index `` method of
160
+ the ``Default `` controller inside the ``FrameworkBundle ``.
160
161
161
- Let's take a look at the last directive of
162
- the configuration file: Symfony2 can include routing information from
163
- other routing configuration files by using the ``import `` directive. In this
164
- case, we want to import the routing configuration from ``HelloBundle ``. A
165
- bundle is like a plugin that has added power and we'll talk more about them
166
- later. For now, let's look at the routing configuration that we've imported:
162
+ Take a look at the last directive of the configuration file: Symfony2 can
163
+ include routing information from other routing configuration files by using
164
+ the ``import `` directive. In this case, we want to import the routing configuration
165
+ from ``HelloBundle ``. A bundle is like a plugin that has added power and
166
+ we'll talk more about them later. For now, let's look at the routing configuration
167
+ that we've imported:
167
168
168
169
.. configuration-block ::
169
170
@@ -202,8 +203,9 @@ later. For now, let's look at the routing configuration that we've imported:
202
203
return $collection;
203
204
204
205
As you can see, the "``/hello/{name} ``" resource pattern is mapped to a controller,
205
- referenced by the ``_controller `` value. The string enclosed in curly brackets (``{name} ``) is a placeholder
206
- and defines an argument that will be available in the controller.
206
+ referenced by the ``_controller `` value. The string enclosed in curly brackets
207
+ (``{name} ``) is a placeholder and defines an argument that will be available
208
+ in the controller.
207
209
208
210
.. index ::
209
211
single: Controller
@@ -235,20 +237,21 @@ The controller defines actions to handle users requests and prepares responses
235
237
}
236
238
}
237
239
238
- Let 's explain this code line by line:
240
+ The code is pretty straightforward but let 's explain it line by line:
239
241
240
242
* *line 3 *: Symfony2 takes advantage of new PHP 5.3 namespacing features,
241
- and all controllers should be properly namespaced. As you can see, the namespace has
242
- a correlation to the actual file location. This is not required, but a best practice.
243
- In this example, the controller lives in the bundle named ``HelloBundle ``,
244
- which forms the first part of the ``_controller `` routing value.
245
-
243
+ and all controllers should be properly namespaced. As you can see, the
244
+ namespace has a correlation to the actual file location. In this example,
245
+ the controller lives in the bundle named ``HelloBundle ``, which forms the
246
+ first part of the ``_controller `` routing value.
247
+
246
248
247
249
* *line 7 *: The controller name is the combination of the second part of the
248
250
``_controller `` routing value (``Hello ``) and the word ``Controller ``. It
249
251
extends the built-in ``Controller `` class, which provides useful shortcuts
250
- (as we will see later in this tutorial). The ``Controller `` resides in ``Symfony\Bundle\FrameworkBundle\Controller\Controller ``
251
- which we defined in line 5
252
+ (as we will see later in this tutorial). The ``Controller `` resides in
253
+ ``Symfony\Bundle\FrameworkBundle\Controller\Controller `` which we defined
254
+ on line 5.
252
255
253
256
* *line 9 *: Each controller consists of several actions. As per the routing
254
257
configuration, the hello page is handled by the ``index `` action (the third
@@ -272,7 +275,7 @@ developers. In our example, we only have one bundle, ``HelloBundle``.
272
275
Templates
273
276
~~~~~~~~~
274
277
275
- The controller renders the ``HelloBundle:Hello:index.html.twig `` template. By
278
+ The controller renders the ``HelloBundle:Hello:index.html.twig `` template. By
276
279
default, the sandbox uses Twig as its template engine but you can also use
277
280
traditional PHP templates if you choose.
278
281
@@ -327,9 +330,9 @@ your changes will appear immediately.
327
330
Final Thoughts
328
331
--------------
329
332
330
- Thanks for trying out Symfony2! By now, you should be able to create your own
331
- simple routes, controllers and templates. As an exercise, try to build
332
- something more useful than the Hello application! If you are eager to
333
+ Thanks for trying out Symfony2! By now, you should be able to create your own
334
+ simple routes, controllers and templates. As an exercise, try to build
335
+ something more useful than the Hello application! If you are eager to
333
336
learn more about Symfony2, dive into the next section: "The View".
334
337
335
338
.. _sandbox : http://symfony-reloaded.org/code#sandbox
0 commit comments