Skip to content

Commit 2613810

Browse files
committed
Added a note about rendering templates from different kernels
1 parent e403fd8 commit 2613810

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

request/multiple_kernels.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@ Then, replace the ``AppKernel`` instantiation by your own kernel instantiation
138138
``bin/api``) can differ because they depend on the bundles enabled for each
139139
kernel, which could be different.
140140

141+
Rendering Templates Defined in a Different Kernel
142+
-------------------------------------------------
143+
144+
If you follow the Symfony Best Practices, the templates of the default kernel
145+
will be stored in ``app/Resources/views/``. Trying to render those templates in
146+
a different kernel will result in a *There are no registered paths for
147+
namespace "__main__"* error.
148+
149+
In order to solve this issue, add the following configuration to your kernel:
150+
151+
.. code-block:: yaml
152+
153+
# api/config/config.yml
154+
twig:
155+
paths:
156+
# allows to use app/Resources/views/ templates in the ApiKernel
157+
"%kernel.root_dir%/../app/Resources/views": ~
158+
141159
Adding more Kernels to the Application
142160
--------------------------------------
143161

0 commit comments

Comments
 (0)