@@ -91,6 +91,14 @@ to creating a page?
91
91
return a ``Response `` object. You'll learn more about :doc: `controllers </controller >`
92
92
in their own section, including how to return JSON responses.
93
93
94
+ .. tip ::
95
+
96
+ To create controllers faster, let Symfony generate it for you:
97
+
98
+ .. code-block :: terminal
99
+
100
+ $ php bin/console make:controller
101
+
94
102
.. _annotation-routes :
95
103
96
104
Annotation Routes
@@ -126,14 +134,6 @@ You can now add your route directly *above* the controller:
126
134
That's it! The page - ``http://localhost:8000/lucky/number `` will work exactly
127
135
like before! Annotations are the recommended way to configure routes.
128
136
129
- .. tip ::
130
-
131
- To create controllers faster, let Symfony generate it for you:
132
-
133
- .. code-block :: terminal
134
-
135
- $ php bin/console make:controller
136
-
137
137
.. _flex-quick-intro :
138
138
139
139
Auto-Installing Recipes with Symfony Flex
@@ -176,36 +176,28 @@ To get a list of *all* of the routes in your system, use the ``debug:router`` co
176
176
177
177
$ php bin/console debug:router
178
178
179
- You should see your * one * route so far :
179
+ You should see your ` app_lucky_number ` route at the very top :
180
180
181
181
================== ======== ======== ====== ===============
182
182
Name Method Scheme Host Path
183
183
================== ======== ======== ====== ===============
184
184
app_lucky_number ANY ANY ANY /lucky/number
185
185
================== ======== ======== ====== ===============
186
186
187
+ You will also see debugging routes below `app_lucky_number ` -- more on the debugging routes in the next section.
188
+
187
189
You'll learn about many more commands as you continue!
188
190
189
191
The Web Debug Toolbar: Debugging Dream
190
192
--------------------------------------
191
193
192
194
One of Symfony's *killer * features is the Web Debug Toolbar: a bar that displays
193
- a *huge * amount of debugging information along the bottom of your page while developing.
194
-
195
- To use the web debug toolbar, install the Profiler pack first:
196
-
197
- .. code-block :: terminal
195
+ a *huge * amount of debugging information along the bottom of your page while developing. This is all
196
+ included out of the box using a package called ``symfony/profiler-pack ``.
198
197
199
- $ composer require --dev symfony/profiler-pack
200
-
201
- As soon as this finishes, refresh your page. You should see a black bar along the
202
- bottom of the page. You'll learn more about all the information it holds along the
203
- way, but feel free to experiment: hover over and click the different icons to get
204
- information about routing, performance, logging and more.
205
-
206
- This is also a great example of Flex! After downloading the profiler package,
207
- the recipe created several configuration files so that the web debug toolbar
208
- worked instantly.
198
+ You will see a black bar along the bottom of the page. You'll learn more about all the information it holds
199
+ along the way, but feel free to experiment: hover over and click
200
+ the different icons to get information about routing, performance, logging and more.
209
201
210
202
Rendering a Template
211
203
--------------------
@@ -214,13 +206,7 @@ If you're returning HTML from your controller, you'll probably want to render
214
206
a template. Fortunately, Symfony comes with `Twig `_: a templating language that's
215
207
easy, powerful and actually quite fun.
216
208
217
- First, install Twig:
218
-
219
- .. code-block :: terminal
220
-
221
- $ composer require symfony/twig-bundle
222
-
223
- Second, make sure that ``LuckyController `` extends Symfony's base
209
+ Make sure that ``LuckyController `` extends Symfony's base
224
210
:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ AbstractController ` class:
225
211
226
212
.. code-block :: diff
@@ -251,9 +237,9 @@ variable so you can use it in Twig::
251
237
{
252
238
$number = random_int(0, 100);
253
239
254
- return $this->render('lucky/number.html.twig', array(
240
+ return $this->render('lucky/number.html.twig', [
255
241
'number' => $number,
256
- ) );
242
+ ] );
257
243
}
258
244
}
259
245
0 commit comments