@@ -403,7 +403,7 @@ have seen so far. All the code you write for your application is organized in
403
403
bundles. In Symfony2 speak, a bundle is a structured set of files (PHP files,
404
404
stylesheets, JavaScripts, images, ...) that implements a single feature (a
405
405
blog, a forum, ...) and which can be easily shared with other developers. As
406
- of now, you have manipulated one bundle, `` AcmeDemoBundle `` . You will learn
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
409
.. _quick-tour-big-picture-environments :
@@ -413,13 +413,13 @@ Working with Environments
413
413
414
414
Now that you have a better understanding of how Symfony2 works, take a closer
415
415
look at the bottom of any Symfony2 rendered page. You should notice a small
416
- bar with the Symfony2 logo. This is called the "Web Debug Toolbar" and it
417
- is the developer's best friend.
416
+ bar with the Symfony2 logo. This is the "Web Debug Toolbar", and it is a
417
+ Symfony2 developer's best friend.
418
418
419
419
.. image :: /images/quick_tour/web_debug_toolbar.png
420
420
:align: center
421
421
422
- But what you see initially is only the tip of the iceberg; click on the long
422
+ What you see initially is only the tip of the iceberg; click on the
423
423
hexadecimal number (the session token) to reveal yet another very useful
424
424
Symfony2 debugging tool: the profiler.
425
425
@@ -428,29 +428,63 @@ Symfony2 debugging tool: the profiler.
428
428
429
429
.. note ::
430
430
431
- You can get more information quickly by hovering over the items on the
432
- Web Debug Toolbar.
431
+ You can also get more information quickly by hovering over the items
432
+ on the Web Debug Toolbar, or clicking them to go to their respective
433
+ pages in the profiler.
434
+
435
+ When loaded (by default in the dev and test environments), and enabled
436
+ (by default, only in the dev environment) the Profiler provides an interface
437
+ to view a great deal of information recorded on each request made to your
438
+ application. It allows you to view details of each request, including, but
439
+ not limited to, GET or POST parameters and the request headers; logs; an
440
+ execution timeline; information on the currently logged in user; Doctrine
441
+ queries; and more.
442
+
443
+ Of course, it would be unwise to have these tools enabled when you deploy
444
+ your application, so by default, the profiler is not enabled in the ``prod ``
445
+ environment. (In fact, its bundle is not even loaded).
446
+
447
+ Symfony2 loads configuration based on the name of the environment. Typically,
448
+ you put your common configuration in ``config.yml `` and override where necessary
449
+ in the configuration for each environment. For example:
433
450
434
- Of course, you won't want to show these tools when you deploy your application
435
- to production. That's why you will find another front controller in the
436
- ``web/ `` directory (``app.php ``), which is optimized for the production environment.
437
- The ``AcmeDemoBundle `` is normally only available in the dev environment (see
438
- the note below), but if you were to add it to the production environment, you
439
- could go here:
451
+ .. code-block :: yaml
452
+
453
+ # app/config/config_dev.yml
454
+ imports :
455
+ - { resource: config.yml }
456
+
457
+ web_profiler :
458
+ toolbar : true
459
+ intercept_redirects : false
460
+
461
+ In this example, the ``dev `` environment loads the ``config_dev.yml `` configuration
462
+ file, which itself imports the global ``config.yml `` file and then modifies it by
463
+ enabling the web debug toolbar.
464
+
465
+ .. tip ::
466
+
467
+ For more details on environments, see ":ref: `Environments & Front Controllers<page-creation-environments> `".
468
+
469
+ The AcmeDemoBundle is normally only available in the dev environment, but
470
+ if you were to add it (and its routes) to the production environment, you could
471
+ go here:
440
472
441
473
.. code-block :: text
442
474
443
475
http://localhost/app.php/demo/hello/Fabien
444
476
445
- And if you use Apache with ``mod_rewrite `` enabled, you can even omit the
446
- ``app.php `` part of the URL:
477
+ If instead of using php's built-in webserver, you use Apache with ``mod_rewrite ``
478
+ enabled and take advantage of the ``.htaccess `` file Symfony2 provides
479
+ in ``web/ ``, you can even omit the ``app.php `` part of the URL. The default
480
+ ``.htaccess `` points all requests to the ``app.php `` front controller:
447
481
448
482
.. code-block :: text
449
483
450
484
http://localhost/demo/hello/Fabien
451
485
452
- Last but not least , on production servers, you should point your web root
453
- directory to the ``web/ `` directory to secure your installation and have an
486
+ Finally , on production servers, you should point your web root directory
487
+ to the ``web/ `` directory to better secure your installation and have an
454
488
even better looking URL:
455
489
456
490
.. code-block :: text
@@ -461,35 +495,11 @@ even better looking URL:
461
495
462
496
Note that the three URLs above are provided here only as **examples ** of
463
497
how a URL looks like when the production front controller is used (with or
464
- without mod_rewrite). If you actually try them in an out of the box
465
- installation of *Symfony Standard Edition * you will get a 404 error as
466
- *AcmeDemoBundle * is enabled only in dev environment and its routes imported
467
- in *app/config/routing_dev.yml *.
468
-
469
- To make your application respond faster, Symfony2 maintains a cache under the
470
- ``app/cache/ `` directory. In the development environment (``app_dev.php ``),
471
- this cache is flushed automatically whenever you make changes to any code or
472
- configuration. But that's not the case in the production environment
473
- (``app.php ``) where performance is key. That's why you should always use
474
- the development environment when developing your application.
475
-
476
- Different :term: `environments<environment> ` of a given application differ
477
- only in their configuration. In fact, a configuration can inherit from another
478
- one:
479
-
480
- .. code-block :: yaml
498
+ without mod_rewrite). If you actually try them in an out-of-the-box
499
+ installation of *Symfony Standard Edition *, you will get a 404 error since
500
+ *AcmeDemoBundle * is enabled only in the dev environment and its routes imported
501
+ from *app/config/routing_dev.yml *.
481
502
482
- # app/config/config_dev.yml
483
- imports :
484
- - { resource: config.yml }
485
-
486
- web_profiler :
487
- toolbar : true
488
- intercept_redirects : false
489
-
490
- The ``dev `` environment (which loads the ``config_dev.yml `` configuration file)
491
- imports the global ``config.yml `` file and then modifies it by, in this example,
492
- enabling the web debug toolbar.
493
503
494
504
Final Thoughts
495
505
--------------
0 commit comments