@@ -63,7 +63,8 @@ Before diving into this, test it out!
63
63
64
64
.. tip ::
65
65
66
- If you setup a proper virtual host in :doc: `Apache or Nginx </cookbook/configuration/web_server_configuration >`,
66
+ If you setup a proper virtual host in
67
+ :doc: `Apache or Nginx </cookbook/configuration/web_server_configuration >`,
67
68
replace ``http://localhost:8000 `` with your host name - like
68
69
``http://symfony.dev/app_dev.php/lucky/number ``.
69
70
@@ -80,22 +81,6 @@ and is where you build the page. The only rule is that a controller *must*
80
81
return a Symfony :ref: `Response <component-http-foundation-response >` object
81
82
(and you'll even learn to bend this rule eventually).
82
83
83
- .. sidebar :: What's the ``app_dev.php`` in the URL?
84
-
85
- Great question! By including ``app_dev.php `` in the URL, you're executing
86
- Symfony through a file - ``web/app_dev.php `` - that boots it in the ``dev ``
87
- environment. This enables great debugging tools and rebuilds cached
88
- files automatically. For production, you'll use clean URLs - like
89
- ``http://symfony.dev/lucky/number `` - that execute a different file -
90
- ``app.php `` - that's optimized for speed.
91
-
92
- When you visit the ``http://localhost:8000 `` URL in your browser, you're
93
- executing your Symfony application in the ``dev `` environment. To visit
94
- your application in the ``prod `` environment, visit the ``http://localhost:8000/app.php ``
95
- URL instead.
96
-
97
- To learn more about this and environments, see :ref: `book-page-creation-prod-cache-clear `.
98
-
99
84
Creating a JSON Response
100
85
~~~~~~~~~~~~~~~~~~~~~~~~
101
86
@@ -132,7 +117,7 @@ Just add a second method to ``LuckyController``::
132
117
133
118
Try this out in your browser:
134
119
135
- http://localhost:8000/app_dev.php/ api/lucky/number
120
+ http://localhost:8000/api/lucky/number
136
121
137
122
You can even shorten this with the handy :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse `::
138
123
@@ -253,7 +238,7 @@ The best part is that you can access this value and use it in your controller::
253
238
254
239
Try it by going to ``/lucky/number/XX `` - replacing XX with *any * number:
255
240
256
- http://localhost:8000/app_dev.php/ lucky/number/7
241
+ http://localhost:8000/lucky/number/7
257
242
258
243
You should see *7 * lucky numbers printed out! You can get the value of any
259
244
``{placeholder} `` in your route by adding a ``$placeholder `` argument to
@@ -410,7 +395,7 @@ to put the content into the middle of the ``base.html.twig`` layout.
410
395
411
396
Refresh to see your template in action!
412
397
413
- http://localhost:8000/app_dev.php/ lucky/number/9
398
+ http://localhost:8000/lucky/number/9
414
399
415
400
If you view the source code, you now have a basic HTML structure thanks to
416
401
``base.html.twig ``.
0 commit comments