Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite403fd8

Browse files
committed
Added a new section about running commands under a different kernel
1 parentaf4ff18 commite403fd8

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎request/multiple_kernels.rst‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ How To Create Symfony Applications with Multiple Kernels
66

77
In most Symfony applications, incoming requests are processed by the
88
``web/app.php`` front controller, which instantiates the ``app/AppKernel.php``
9-
class to create the application kernel that loads the bundles andgenerates the
10-
response.
9+
class to create the application kernel that loads the bundles andhandles the
10+
request to generate theresponse.
1111

1212
This single kernel approach is a convenient default provided by the Symfony
1313
Standard edition, but Symfony applications can define any number of kernels.
@@ -45,10 +45,8 @@ Step 1) Create a new Front Controller
4545
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4646

4747
Instead of creating the new front controller from scratch, it's recommended to
48-
duplicate the existing ``web/app_dev.php`` and ``web/app.php`` files. For
49-
example, you can create ``web/api_dev.php`` and ``web/api.php`` (or
50-
``web/api/app_dev.php`` and ``web/api/app.php`` depending on your server
51-
configuration).
48+
duplicate the existing ones. For example, create ``web/api_dev.php`` from
49+
``web/app_dev.php`` and ``web/api.php`` from ``web/app.php``.
5250

5351
Then, update the code of the new front controllers to instantiate the new kernel
5452
class instead of the usual ``AppKernel`` class::
@@ -122,6 +120,24 @@ config files or better, import them and override the needed options:
122120
123121
# override option values ...
124122
123+
Executing Commands with a Different Kernel
124+
------------------------------------------
125+
126+
The ``bin/console`` script used to run Symfony commands always uses the default
127+
``AppKernel`` class to build the application and load the commands. If you need
128+
to execute console commands using the new kernel, duplicate the ``bin/console``
129+
script and rename it (e.g. ``bin/api``).
130+
131+
Then, replace the ``AppKernel`` instantiation by your own kernel instantiation
132+
(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
134+
135+
..note::
136+
137+
The commands available for each console script (e.g. ``bin/console`` and
138+
``bin/api``) can differ because they depend on the bundles enabled for each
139+
kernel, which could be different.
140+
125141
Adding more Kernels to the Application
126142
--------------------------------------
127143

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp