@@ -61,37 +61,24 @@ random) number and prints it. To do that, create a "Controller class" and a
61
61
}
62
62
}
63
63
64
- "Controller class" is a convenient way to group several "controllers" together.
65
-
66
64
Before diving into this, test it out! If you are using PHP's internal web server
67
65
go to:
68
66
69
67
http://localhost:8000/lucky/number
70
68
71
- If you set up a proper virtual host in Apache or Nginx replace ``http://localhost:8000 ``
72
- with your host name and add the name of the development front controller file you
73
- are using `` web/app_dev.php `` :
69
+ If you set up a virtual host in Apache or Nginx replace ``http://localhost:8000 ``
70
+ with your host name and add `` app_dev.php `` to make sure Symfony loads in the "dev"
71
+ environment :
74
72
75
73
http://symfony.dev/app_dev.php/lucky/number
76
74
77
75
If you see a lucky number being printed back to you, congratulations! But before
78
76
you run off to play the lottery, check out how this works.
79
77
80
- The ``@Route `` above ``numberAction() `` method is called an :term: `annotation `
81
- and defines the route so that :doc: `Router </book/routing >` can match the incoming URL
82
- (``http://localhost:8000/lucky/number ``) to a specific route (``/lucky/number ``)
83
- and therefore returns information about the route, including the controller method
84
- that should be executed. The correct controller from the matched route is executed
85
- and the code inside the controller creates and returns the appropriate ``Response ``
86
- object.
87
-
88
- .. note ::
89
-
90
- You can also write routes in YAML, XML or PHP: you will learn about
91
- this in the :doc: `Routing </book/routing >` chapter. If you look closer
92
- the above example has tabs that show you how each format looks - all three additional
93
- formats use routing configuration file to define routes. Actually, most
94
- routing examples in the docs have tabs that show you how each format looks.
78
+ The ``@Route `` above ``numberAction() `` method is called an *annotation * and it
79
+ defines the URL pattern. You can also write routes in YAML (or other formats):
80
+ read about this in the :doc: `routing </book/routing >` chapter. Actually, most
81
+ routing examples in the docs have tabs that show you how each format looks.
95
82
96
83
Creating a JSON Response
97
84
~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments