@@ -44,7 +44,7 @@ Symfony application.
44
44
Step 1) Create a new Front Controller
45
45
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
46
47
- Instead of creating the new front controller from scratch, it's recommended to
47
+ Instead of creating the new front controller from scratch, it's easier to
48
48
duplicate the existing ones. For example, create ``web/api_dev.php `` from
49
49
``web/app_dev.php `` and ``web/api.php `` from ``web/app.php ``.
50
50
@@ -65,16 +65,14 @@ Step 2) Create the new Kernel Class
65
65
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66
66
67
67
Now you need to define the ``ApiKernel `` class used by the new front controller.
68
- The recommendation again is to duplicate the existing ``app/AppKernel.php `` file
69
- and make the needed changes.
68
+ The easiest way to do this is by duplicating the existing ``app/AppKernel.php ``
69
+ file and make the needed changes.
70
70
71
- In this example, the changes of the new ``ApiKernel `` would be to load less
72
- bundles than `` AppKernel `` and to change the location of the cache, logs and
73
- config files to not mess with the regular application ::
71
+ In this example, the ``ApiKernel `` will load less bundles than AppKernel. Be
72
+ sure to also change the location of the cache, logs and configuration files so
73
+ they don't collide with the files from `` AppKernel `` ::
74
74
75
75
// app/ApiKernel.php
76
- <?php
77
-
78
76
use Symfony\Component\HttpKernel\Kernel;
79
77
use Symfony\Component\Config\Loader\LoaderInterface;
80
78
@@ -104,9 +102,9 @@ config files to not mess with the regular application::
104
102
Step 3) Define the Kernel Configuration
105
103
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
104
107
- Finally, define the configuration used by the application when it executes the
108
- new API kernel. According to the previous code, this config must be defined in
109
- the `` app/config/api/ `` directory.
105
+ Finally, define the configuration files that the new `` ApiKernel `` will load.
106
+ According to the above code, this config will live in the `` app/config/api/ ``
107
+ directory.
110
108
111
109
The new configuration can be created from scratch when you load just a few
112
110
bundles, because it will be very simple. Otherwise, duplicate the existing
@@ -130,7 +128,8 @@ script and rename it (e.g. ``bin/api``).
130
128
131
129
Then, replace the ``AppKernel `` instantiation by your own kernel instantiation
132
130
(e.g. ``ApiKernel ``) and now you can execute commands using the new kernel
133
- (e.g. ``php bin/api cache:clear ``) Now you can use execute commands using the new kernel
131
+ (e.g. ``php bin/api cache:clear ``) Now you can use execute commands using the
132
+ new kernel.
134
133
135
134
.. note ::
136
135
@@ -160,7 +159,7 @@ Adding more Kernels to the Application
160
159
--------------------------------------
161
160
162
161
If your application is very complex and you create several kernels, it's better
163
- to store them on their own directories instead of messing with lots of files in
162
+ to store them in their own directories instead of messing with lots of files in
164
163
the default ``app/ `` directory:
165
164
166
165
.. code-block :: text
0 commit comments