@@ -406,26 +406,41 @@ blog, a forum, ...) and which can be easily shared with other developers. As
406
406
of now, you have manipulated one bundle, AcmeDemoBundle. You will learn
407
407
more about bundles in the last chapter of this tutorial.
408
408
409
- Environments
410
- ~~~~~~~~~~~~
411
-
412
- Every Symfony application runs within an :term: `environment `. An environment
413
- is a specific set of configuration and loaded bundles, represented by a string.
414
- The same application can be run with different configurations by running the
415
- application in different environments. Symfony2 comes with three environments
416
- defined — ``dev ``, ``test `` and ``prod `` — but you can create your own as well.
417
-
418
- Environments are useful by allowing a single application to have a dev environment
419
- built for debugging and a production environment optimized for speed. You might
420
- also load specific bundles based on the selected environment. For example,
421
- Symfony2 comes with the WebProfilerBundle (described below), enabled only
422
- in the ``dev `` and ``test `` environments.
423
-
424
409
.. _quick-tour-big-picture-environments :
425
410
426
411
Working with Environments
427
412
-------------------------
428
413
414
+ Now that you have a better understanding of how Symfony2 works, take a closer
415
+ look at the bottom of any Symfony2 rendered page. You should notice a small
416
+ bar with the Symfony2 logo. This is the "Web Debug Toolbar", and it is a
417
+ Symfony2 developer's best friend.
418
+
419
+ .. image :: /images/quick_tour/web_debug_toolbar.png
420
+ :align: center
421
+
422
+ What you see initially is only the tip of the iceberg; click on the long
423
+ hexadecimal number (the session token) to reveal yet another very useful
424
+ Symfony2 debugging tool: the profiler.
425
+
426
+ .. image :: /images/quick_tour/profiler.png
427
+ :align: center
428
+
429
+ .. note ::
430
+
431
+ You can also get more information quickly by hovering over the items
432
+ on the Web Debug Toolbar.
433
+
434
+ When enabled (by default in the dev and test environments), the Profiler
435
+ records a great deal of information on each request made to your application.
436
+ It allows you to view details of each request, including, but not limited to,
437
+ GET or POST parameters and the request headers; logs; an execution timeline;
438
+ information on the currently logged in user; Doctrine queries; and more.
439
+
440
+ Of course, it would be unwise to have these tools enabled when you deploy
441
+ your application, so by default, the profiler is not enabled in the ``prod ``
442
+ environment. (In fact, its bundle is not even loaded).
443
+
429
444
Symfony2 loads configuration based on the name of the environment. Typically,
430
445
you put your common configuration in ``config.yml `` and override where necessary
431
446
in the configuration for each environment. For example:
@@ -444,18 +459,9 @@ In this example, the ``dev`` environment loads the ``config_dev.yml`` configurat
444
459
file, which itself imports the global ``config.yml `` file and then modifies it by
445
460
enabling the web debug toolbar.
446
461
447
- To make your application respond faster, Symfony2 maintains a cache under the
448
- ``app/cache/ `` directory. In the ``dev `` environment, this cache is flushed
449
- automatically whenever you make changes to any code or configuration. But that's
450
- not the case in the ``prod `` environment, where performance is key. That's why you
451
- should always use the development environment when developing your application.
462
+ .. tip ::
452
463
453
- Symfony2 comes with two web-accessible front controllers: ``app_dev.php ``
454
- provides the ``dev `` environment, and ``app.php `` provides the ``prod `` environment.
455
- All web accesses to Symfony2 normally go through one of these front controllers.
456
- (The ``test `` environment is normally only used when running unit tests, and so
457
- doesn't have a dedicated front controller. The console tool also provides a
458
- front controller that can be used with any environment.)
464
+ For more details on environments, see ":ref: `Environments & Front Controllers<page-creation-environments> `".
459
465
460
466
The AcmeDemoBundle is normally only available in the dev environment, but
461
467
if you were to add it (and its routes) to the production environment, you could
@@ -491,42 +497,6 @@ even better looking URL:
491
497
*AcmeDemoBundle * is enabled only in the dev environment and its routes imported
492
498
from *app/config/routing_dev.yml *.
493
499
494
- .. _quick-tour-big-picture-web-debug-toolbar :
495
-
496
- The Web Debug Toolbar and Profiler
497
- ----------------------------------
498
-
499
-
500
- Now that you have a better understanding of how Symfony2 works, take a closer
501
- look at the bottom of any Symfony2 rendered page. You should notice a small
502
- bar with the Symfony2 logo. This is the "Web Debug Toolbar", and it is a
503
- Symfony2 developer's best friend.
504
-
505
- .. image :: /images/quick_tour/web_debug_toolbar.png
506
- :align: center
507
-
508
- What you see initially is only the tip of the iceberg; click on the long
509
- hexadecimal number (the session token) to reveal yet another very useful
510
- Symfony2 debugging tool: the profiler.
511
-
512
- .. image :: /images/quick_tour/profiler.png
513
- :align: center
514
-
515
- When enabled (by default in the dev and test environments), the Profiler
516
- records a great deal of information on each request made to your application.
517
- It allows you to view details of each request, including, but not limited to,
518
- GET or POST parameters and the request headers; logs; an execution timeline;
519
- information on the currently logged in user; Doctrine queries; and more.
520
-
521
- Of course, it would be unwise to have these tools enabled when you deploy
522
- your application, so by default, the profiler is not enabled in the ``prod ``
523
- environment. (In fact, its bundle is not even loaded).
524
-
525
- .. note ::
526
-
527
- You can get more information quickly by hovering over the items on the
528
- Web Debug Toolbar.
529
-
530
500
531
501
Final Thoughts
532
502
--------------
0 commit comments