Skip to content

Commit 5a4bb99

Browse files
mpdudeweaverryan
authored andcommitted
Even more GH feedback, some additional notes and typos
1 parent 6286451 commit 5a4bb99

File tree

1 file changed

+55
-24
lines changed

1 file changed

+55
-24
lines changed

cookbook/configuration/front_controllers_and_kernel.rst

+55-24
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ These are the very first PHP scripts executed when a request is
3939
processed.
4040

4141
The main purpose of the front controller is to create an instance of the
42-
``AppKernel`` (more on that in a second), make it handle the reques and
43-
return the resulting response to the browser.
42+
``AppKernel`` (more on that in a second), make it handle the request
43+
and return the resulting response to the browser.
4444

4545
Because every request is routed through it, the front controller can be
4646
used to perform global initializations prior to setting up the kernel or
@@ -67,12 +67,17 @@ will use ``app.php`` as the default one.
6767

6868
.. note::
6969

70-
When adding a custom front controller and/or using the
71-
provided RewriteRule in production, make sure to appropriately
72-
secure it agains unauthorized access.
70+
Pretty much every other web server should be able to achieve a
71+
behavior similar to that of the RewriteRule described above.
72+
Check your server documentation for details.
7373

74-
For example, you don't want to make the debug toolbar available
75-
to arbitraty users in your production environment.
74+
.. note::
75+
76+
Make sure you appropriately
77+
secure your front controllers against unauthorized access.
78+
79+
For example, you don't want to make a debugging environment
80+
available to arbitraty users in your production environment.
7681

7782
Technically, the ``app/console``_ used when running
7883
Symfony on the command line is also a front controller,
@@ -104,7 +109,7 @@ To fill these (small) blanks, your application needs to subclass the
104109
Kernel and implement these methods. The resulting class is
105110
conventionally called the ``AppKernel``.
106111

107-
Again, the Symfony2 Standard Edition provides an ```AppKernel```_ in
112+
Again, the Symfony2 Standard Edition provides an `AppKernel`_ in
108113
the
109114
``app/`` directory. This class
110115
uses the name of the environment, which is passed to the Kernel's
@@ -117,30 +122,56 @@ application.
117122

118123
You are, of course, free to create your own, alternative or additional
119124
``AppKernel`` variants. All you need is to adapt your (or add a new) front
120-
controller to make use of the new kernel. Adding additional kernel
121-
implementations might be useful to
125+
controller to make use of the new kernel.
126+
127+
.. note::
128+
129+
The name and location of the ``AppKernel`` is not fixed. When
130+
putting multiple Kernels into a single application,
131+
it might therefore make sense to add additional sub-directories,
132+
for example ``app/admin/AdminKernel.php`` and
133+
``app/api/ApiKernel.php``. All that matters is that your front
134+
controller is able to create an instance of the appropriate
135+
kernel.
122136

123-
* easily switch between different set of bundles to work with, without
124-
creating too complicated ``if...else...`` constructs in the
125-
:method:`Symfony\\Component\\HttpKernel\\HttpKernel::registerBundles`
126-
method or
127-
* add more sophisticated ways of loading the application's configuration
128-
from a different set of files.
137+
Having different ``AppKernels`` might be useful to enable different
138+
front controllers (on potentially different servers) to run parts of
139+
your application independently (for example, the admin UI,
140+
the frontend UI and database migrations).
141+
142+
.. note::
143+
144+
There's a lot more the ``AppKernel`` can be used for,
145+
for example :doc:`overriding the default
146+
directory structure
147+
</cookbook/configuration /override_dir_structure>`. But odds are
148+
high that you don't need to change such things on the fly by
149+
having several ``AppKernel`` implementations at hand.
129150

130151
The environments
131152
================
132153

154+
We just mentioned another method the ``AppKernel`` has to implement -
155+
:method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration`.
156+
This method is responsible for loading the application's
157+
configuration from the right *environment*.
158+
133159
Environments have been covered extensively
134-
:doc:`in the previous chapter</cookbook/configuration/environments>`.
135-
You probably remember that an environment is nothing more than a name (a
136-
string) passed to the Kernel's constructor which is in turn used to
137-
determine which set of configuration files the Kernel is supposed to
138-
load - and this is what the missing
160+
:doc:`in the previous chapter</cookbook/configuration/environments>`,
161+
and you probably remember that the Standard Edition comes with three
162+
of them - ``dev``, ``prod`` and ``test``.
163+
164+
More technically, these names are nothing more than strings passed
165+
from the front controller to the ``AppKernel``'s constructor. This
166+
name can then be used in
139167
:method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration`
140-
method is used for.
168+
method to decide which configuration files to load.
141169

142-
The Standard Edition's ``AppKernel``_ class implements this method by
143-
simply loading the ``app/config/config_*environment*.yml`` file.
170+
The Standard
171+
Edition's ``AppKernel``_ class implements this method by
172+
simply loading the ``app/config/config_*environment*.yml`` file. You
173+
are, of course, free to implement this method differently if you need
174+
a more sophisticated way of loading your configuration.
144175

145176
.. _front controller: http://en.wikipedia.org/wiki/Front_Controller_pattern
146177
.. _Symfony 2 Standard Edition: https://github.com/symfony/symfony-standard

0 commit comments

Comments
 (0)