Skip to content

Commit fd3b1d7

Browse files
committed
[#6840] Adding note based on Stof's feedback
1 parent 0257f95 commit fd3b1d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

configuration/multiple_kernels.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ class instead of the usual ``AppKernel`` class::
6161
$kernel = new ApiKernel('dev', true);
6262
// ...
6363

64+
.. tip::
65+
66+
Another approach is to keep the existing front controller (e.g. ``app.php`` and
67+
``app_dev.php``), but add an ``if`` statement to load the different kernel based
68+
on the URL (e.g. if the URL starts with ``/api``, use the ``ApiKernel``).
69+
6470
Step 2) Create the new Kernel Class
6571
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6672

@@ -99,6 +105,20 @@ they don't collide with the files from ``AppKernel``::
99105
}
100106
}
101107

108+
In order for the autoloader to find your new ``ApiKernel``, make sure you add it
109+
to your ``composer.json`` autoload section:
110+
111+
{
112+
"...": "..."
113+
114+
"autoload": {
115+
"psr-4": { "": "src/" },
116+
"classmap": [ "app/AppKernel.php", "app/AppCache.php", "app/ApiKernel.php" ]
117+
}
118+
}
119+
120+
Then, run ``composer install`` to dump your new autoload config.
121+
102122
Step 3) Define the Kernel Configuration
103123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104124

0 commit comments

Comments
 (0)