@@ -75,11 +75,16 @@ environment:
7575If you see a lucky number being printed back to you, congratulations! But before
7676you run off to play the lottery, check out how this works.
7777
78- The ``@Route `` above ``numberAction() `` method is called an *annotation * and it
78+ The ``@Route `` above ``numberAction() `` is called an *annotation * and it
7979defines the URL pattern. You can also write routes in YAML (or other formats):
8080read about this in the :doc: `routing </book/routing >` chapter. Actually, most
8181routing examples in the docs have tabs that show you how each format looks.
8282
83+ The method below the annotation - ``numberAction `` - is called the *controller *
84+ and is where you build the page. The only rule is that a controller *must *
85+ return a Symfony :ref: `Response <component-http-foundation-response >` object
86+ (and you'll even learn to bend this rule eventually).
87+
8388Creating a JSON Response
8489~~~~~~~~~~~~~~~~~~~~~~~~
8590
@@ -150,8 +155,8 @@ Dynamic URL Patterns: /lucky/number/{count}
150155
151156Woh, you're doing great! But Symfony's routing can do a lot more. Suppose
152157now that you want a user to be able to go to ``/lucky/number/5 `` to generate
153- *5 * lucky numbers at once. Update the route to have a " wildcard" placeholders
154- `` {counter} `` at the end: :
158+ *5 * lucky numbers at once. Update the route to have a `` { wildcard} `` part
159+ at the end:
155160
156161.. configuration-block ::
157162
@@ -207,7 +212,7 @@ now that you want a user to be able to go to ``/lucky/number/5`` to generate
207212
208213 return $collection;
209214
210- Because of the ``{count} `` "wildcard" placeholders , the URL to the page is *different *:
215+ Because of the ``{count} `` "wildcard" placeholder , the URL to the page is *different *:
211216it now works for URLs matching ``/lucky/number/* `` - for example ``/lucky/number/5 ``.
212217The best part is that you can access this value and use it in your controller::
213218
@@ -241,8 +246,8 @@ Try it by printing *7* lucky numbers:
241246 http://localhost:8000/lucky/number/7
242247
243248**You can get the value of any ``{placeholder}`` in your route by adding
244- a ``$placeholder`` argument to your controller. Just make sure they have
245- the same name. **
249+ a ``$placeholder`` argument to your controller. Just make sure that the placeholder
250+ (e.g. ``{id}``) matches the argument name (e.g. ``$id``) . **
246251
247252The routing system can do a *lot * more, like supporting multiple placeholders
248253(e.g. ``/blog/{category}/{page}) ``), making placeholders optional and forcing
@@ -356,7 +361,7 @@ If you refresh your browser now, you'll get an error:
356361 Unable to find template "lucky/number.html.twig"
357362
358363Fix that by creating a new ``app/Resources/views/lucky `` directory and putting
359- a ``number.html.twig `` file inside of it::
364+ a ``number.html.twig `` file inside of it:
360365
361366.. configuration-block ::
362367
@@ -380,14 +385,13 @@ a ``number.html.twig`` file inside of it::
380385
381386Welcome to Twig! This simple file already shows off the basics:
382387
383- * ``{{ variableName }} `` syntax is used to print a variable that you're
384- passing into the template from the array list in `` render() `` method in your
385- controller.
388+ * The ``{{ variableName }} `` syntax is used to print something. In this template,
389+ `` luckyNumberList `` is a variable that you're passing into the template from the
390+ `` render `` call in the controller.
386391
387392* The ``{% extends 'base.html.twig' %} `` points to a layout file that lives
388- at `app/Resources/views/base.html.twig `_ and came with your new project
389- Symfony Standard Edition. It's *really * basic (an unstyled HTML structure)
390- and it's yours to customize.
393+ at `app/Resources/views/base.html.twig `_ and came with your new project. It's
394+ *really * basic (an unstyled HTML structure) and it's yours to customize.
391395
392396* The ``{% block body %} `` part uses Twig's :ref: `inheritance system <twig-inheritance >`
393397 to put the content into the middle of the ``base.html.twig `` layout.
@@ -441,8 +445,8 @@ the :doc:`Bundles </book/bundles>` chapter.
441445So what about the other directories in the project?
442446
443447``vendor/ ``
444- Location to which vendor (i.e. third-party ) libraries and bundles are
445- downloaded by the `Composer `_ package manager.
448+ Third-party (i.e. "vendor" ) libraries live here! These are typically downloaded
449+ via the `Composer `_ package manager.
446450
447451``web/ ``
448452 This is the document root for the project and contains any publicly accessible
@@ -452,15 +456,14 @@ So what about the other directories in the project?
452456.. seealso ::
453457
454458 Symfony is flexible. If you need to, you can easily override the default
455- directory structure. See cookbook article
456- :doc: `/cookbook/configuration/override_dir_structure `.
459+ directory structure. See :doc: `/cookbook/configuration/override_dir_structure `.
457460
458461Application Configuration
459462-------------------------
460463
461- Symfony Standard Edition comes with several built-in bundles (open your
462- `` app/AppKernel.php `` file) and you'll probably install more. The main configuration
463- file for bundles is ``app/config/config.yml ``: :
464+ Symfony comes with several built-in bundles (open your `` app/AppKernel.php ``
465+ file) and you'll probably install more. The main configuration file for bundles
466+ is ``app/config/config.yml ``:
464467
465468.. configuration-block ::
466469
@@ -530,8 +533,8 @@ file for bundles is ``app/config/config.yml``::
530533
531534 // ...
532535
533- The ``framework `` key configures `` FrameworkBundle `` , the ``twig `` key configures
534- `` TwigBundle `` and so on. A *lot * of behavior in Symfony can be controlled just
536+ The ``framework `` key configures FrameworkBundle, the ``twig `` key configures
537+ TwigBundle and so on. A *lot * of behavior in Symfony can be controlled just
535538by changing one option in this configuration file. To find out how, see the
536539:doc: `Configuration Reference </reference/index >` section.
537540
0 commit comments