File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ class instead of the usual ``AppKernel`` class::
61
61
$kernel = new ApiKernel('dev', true);
62
62
// ...
63
63
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
+
64
70
Step 2) Create the new Kernel Class
65
71
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66
72
@@ -99,6 +105,20 @@ they don't collide with the files from ``AppKernel``::
99
105
}
100
106
}
101
107
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
+
102
122
Step 3) Define the Kernel Configuration
103
123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
124
You can’t perform that action at this time.
0 commit comments