Skip to content

Commit 9690dce

Browse files
committed
Big Picture Environments cleanups
* Move the environments and front controller discussions to book/page_creation * This allows for the debug toolbar discussion to be more prominent
1 parent 95ba03b commit 9690dce

File tree

2 files changed

+66
-62
lines changed

2 files changed

+66
-62
lines changed

book/page_creation.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,40 @@ HTTP response.
2222
Symfony2 follows this philosophy and provides you with tools and conventions
2323
to keep your application organized as it grows in users and complexity.
2424

25+
.. index::
26+
single: Page creation; Environments & Front Controllers
27+
28+
.. _page-creation-environments:
29+
30+
Environments & Front Controllers
31+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
Every Symfony application runs within an :term:`environment`. An environment
34+
is a specific set of configuration and loaded bundles, represented by a string.
35+
The same application can be run with different configurations by running the
36+
application in different environments. Symfony2 comes with three environments
37+
defined — ``dev``, ``test`` and ``prod`` — but you can create your own as well.
38+
39+
Environments are useful by allowing a single application to have a dev environment
40+
built for debugging and a production environment optimized for speed. You might
41+
also load specific bundles based on the selected environment. For example,
42+
Symfony2 comes with the WebProfilerBundle (described below), enabled only
43+
in the ``dev`` and ``test`` environments.
44+
45+
To make your application respond faster, Symfony2 maintains a cache under the
46+
``app/cache/`` directory. In the ``dev`` environment, this cache is flushed
47+
automatically whenever you make changes to any code or configuration. But that's
48+
not the case in the ``prod`` environment, where performance is key. That's why you
49+
should always use the development environment when developing your application.
50+
51+
Symfony2 comes with two web-accessible front controllers: ``app_dev.php``
52+
provides the ``dev`` environment, and ``app.php`` provides the ``prod`` environment.
53+
All web accesses to Symfony2 normally go through one of these front controllers.
54+
(The ``test`` environment is normally only used when running unit tests, and so
55+
doesn't have a dedicated front controller. The console tool also provides a
56+
front controller that can be used with any environment.)
57+
58+
2559
.. index::
2660
single: Page creation; Example
2761

quick_tour/the_big_picture.rst

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -406,26 +406,41 @@ blog, a forum, ...) and which can be easily shared with other developers. As
406406
of now, you have manipulated one bundle, AcmeDemoBundle. You will learn
407407
more about bundles in the last chapter of this tutorial.
408408

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-
424409
.. _quick-tour-big-picture-environments:
425410

426411
Working with Environments
427412
-------------------------
428413

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+
429444
Symfony2 loads configuration based on the name of the environment. Typically,
430445
you put your common configuration in ``config.yml`` and override where necessary
431446
in the configuration for each environment. For example:
@@ -444,18 +459,9 @@ In this example, the ``dev`` environment loads the ``config_dev.yml`` configurat
444459
file, which itself imports the global ``config.yml`` file and then modifies it by
445460
enabling the web debug toolbar.
446461

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::
452463

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>`".
459465

460466
The AcmeDemoBundle is normally only available in the dev environment, but
461467
if you were to add it (and its routes) to the production environment, you could
@@ -491,42 +497,6 @@ even better looking URL:
491497
*AcmeDemoBundle* is enabled only in the dev environment and its routes imported
492498
from *app/config/routing_dev.yml*.
493499

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-
530500

531501
Final Thoughts
532502
--------------

0 commit comments

Comments
 (0)