@@ -59,7 +59,7 @@ because that will be explained in the next section)::
59
59
/**
60
60
* @Route("/", name="homepage")
61
61
*/
62
- public function indexAction ()
62
+ public function index ()
63
63
{
64
64
return $this->render('default/index.html.twig', [
65
65
// ...
@@ -69,12 +69,12 @@ because that will be explained in the next section)::
69
69
70
70
In Symfony applications, **controllers ** are usually PHP classes whose names
71
71
are suffixed with the ``Controller `` word. In this example, the controller
72
- is called ``Default `` and the PHP class is called `` DefaultController ``.
72
+ is called ``DefaultController ``.
73
73
74
74
The methods defined in a controller are called **actions **, they are usually
75
75
associated with one URL of the application and their names are suffixed
76
- with ``Action ``. In this example, the ``Default `` controller has only one
77
- action called ``index `` and defined in the `` indexAction () `` method .
76
+ with ``Action ``. In this example, the ``DefaultController `` has only one
77
+ action called ``index() ``.
78
78
79
79
Actions are usually very short - around 10-15 lines of code - because they
80
80
just call other parts of the application to get or generate the needed
@@ -90,7 +90,7 @@ Routing
90
90
Symfony routes each request to the action that handles it by matching the
91
91
requested URL against the paths configured by the application. Open again
92
92
the ``src/Controller/DefaultController.php `` file and take a look
93
- at the three lines of code above the ``indexAction () `` method::
93
+ at the three lines of code above the ``index () `` method::
94
94
95
95
// src/Controller/DefaultController.php
96
96
namespace App\Controller;
@@ -103,7 +103,7 @@ at the three lines of code above the ``indexAction()`` method::
103
103
/**
104
104
* @Route("/", name="homepage")
105
105
*/
106
- public function indexAction ()
106
+ public function index ()
107
107
{
108
108
return $this->render('default/index.html.twig', [
109
109
// ...
@@ -126,7 +126,7 @@ but later it'll be useful for linking pages.
126
126
127
127
Considering all this, the ``@Route("/", name="homepage") `` annotation creates a
128
128
new route called ``homepage `` which makes Symfony execute the ``index `` action
129
- of the ``Default `` controller when the user browses the ``/ `` path of the application.
129
+ of the ``DefaultController `` when the user browses the ``/ `` path of the application.
130
130
131
131
.. tip ::
132
132
@@ -175,9 +175,9 @@ Working with Environments
175
175
-------------------------
176
176
177
177
Now that you have a better understanding of how Symfony works, take a closer
178
- look at the bottom of any Symfony rendered page. You should notice a small
179
- bar with the Symfony logo. This is the "web debug toolbar" and it is a Symfony
180
- developer's best friend!
178
+ look at the bottom of any Symfony rendered page. If you've installed the profiler
179
+ with `` composer require profiler ``, you should notice a small bar with the Symfony
180
+ logo. This is the "web debug toolbar" and it is a Symfony developer's best friend!
181
181
182
182
.. image :: /_images/quick_tour/web_debug_toolbar.png
183
183
:align: center
@@ -210,11 +210,12 @@ application. Symfony defines two environments by default: ``dev`` (suited for
210
210
when developing the application locally) and ``prod `` (optimized for when
211
211
executing the application on production).
212
212
213
- When you visit the ``http://localhost:8000 `` URL in your browser, you're
214
- executing your Symfony application in the ``dev `` environment. To visit
215
- your application in the ``prod `` environment, visit the ``http://localhost:8000/index.php ``
216
- URL instead. If you prefer to always show the ``dev `` environment in the
217
- URL, you can visit ``http://localhost:8000/index.php `` URL.
213
+ The environment is determined by the ``APP_ENV `` environment variable, which is
214
+ set in the ``.env `` file while developing. By default, this value is set to ``dev ``.
215
+ This means that, right now, hen you visit the ``http://localhost:8000 `` URL in your
216
+ browser, you're executing your Symfony application in the ``dev `` environment. To
217
+ visit your application in the ``prod `` environment, open your ``.env `` file and
218
+ set ``APP_ENV `` to ``prod `` and ``APP_DEBUG `` to ``0 ``.
218
219
219
220
The main difference between environments is that ``dev `` is optimized to
220
221
provide lots of information to the developer, which means worse application
@@ -224,26 +225,30 @@ toolbar.
224
225
225
226
The other difference between environments is the configuration options used
226
227
to execute the application. When you access the ``dev `` environment, Symfony
227
- loads the ``app/config/config_dev.yml `` configuration file. When you access
228
- the ``prod `` environment, Symfony loads ``app/config/config_prod.yml `` file.
228
+ loads any configuration files from the ``config/packages/dev `` directory. When you
229
+ access the ``prod `` environment, Symfony loads files from the ``config/packages/prod ``
230
+ directory.
229
231
230
232
Typically, the environments share a large amount of configuration options.
231
- For that reason, you put your common configuration in ``config.yml `` and
232
- override the specific configuration file for each environment where necessary:
233
+ For that reason, any configuration files stored directly in ``config/packages ``
234
+ are loaded in *all * environments. Then, configuration files in the ``dev/ `` sub-directory
235
+ can *override * that config.
233
236
234
237
.. code-block :: yaml
235
238
236
- # app/config/config_dev.yml
237
- imports :
238
- - { resource: config.yml }
239
+ # config/packages/routing.yaml
240
+ framework :
241
+ router :
242
+ strict_requirements : ~
239
243
240
- web_profiler :
241
- toolbar : true
242
- intercept_redirects : false
244
+ .. code-block :: yaml
245
+ # config/packages/dev/routing.yaml
246
+ framework :
247
+ router :
248
+ strict_requirements : true
243
249
244
- In this example, the ``config_dev.yml `` configuration file imports the common
245
- ``config.yml `` file and then overrides any existing web debug toolbar configuration
246
- with its own options.
250
+ In this example, the ``strict_requirements `` is overridden and set to ``true ``
251
+ *only * in the ``dev `` environment.
247
252
248
253
For more details on environments, see
249
254
:ref: `the "Environments" section <page-creation-environments >` of the
0 commit comments