-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
add a cookbook entry about how to have multiple kernels #997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think if we can find a decent use case (and then strongly warn people that they probably don't need this), then I think it's a great idea. I want to make sure that even if we teach people how, we make sure they ask whether or not they actually need this :). |
when this is documented, we can link to it from |
You think #2465 solved this? If not, what do you think is missing? |
I like to have some stronger warning that you properbly do not need this. And I like to have some interlinking from reference/configuration/kernel#kernel.name |
As to kernel.name, by coincidence I came across that today. I did not really see what it is important for and how it should be best chosen. If you can help me to understand that I'd be glad to improve the docs. Update: Same for the kernel.root_dir. What should that best point to and is it important for anything besides being a base for the cache and logs dir? |
Well, first of all, I maened we cannlink to this article from the kernle.name setting description. The kernel name is used when generating the classes for the container or routing. The default value will work in most of the cases and you won't worry about it. The kernel.root_dir is the only path that is known by symfony. All included configuration and other things are based on it. This one usually don't need to be overriden too. Please note some comment by stof:
That's something different than the cookbook article explains it:
|
@wouterj The issue with moving the structure of |
@weaverryan why would they don't strongly need this? I have been in places where we implemented this and also I got advised back long ago by merk about this too. Usually the use case is a front end with a quick rest api. If you can shed light please it would be great. Thanks man! |
@cordoval strongly warn people about not doing this until they have a good use case. An API versus a normal app seems like a good use-case. |
@kbond I've just read this comment that you made on Bundles, No Bundles and AppBundle in 10 Steps:
Could you please share with us some of those multi-kernel projects scenarios? This is something we want to document since a lot of time ago and we need someone to outline some basic ideas for the cookbook. Thanks in advance for your help! |
And I had the same experience as @kbond - I was surprised (at least by conference-goers) by how many people had multiple kernels. @meandmymonkey also mentioned some use-cases beyond an API backend and web frontend, like a kernel just for commands (the advantage being the kernel is a bit slimmer, which is not important for many, but important if you're squeezing performance). I still think that most people don't need this, but it's definitely a legitimate use-case, and this entry would really be quite simple to write. @javiereguiluz thanks for re-pinging :). |
@javiereguiluz the only scenarios I can recall are the ones Ryan mentioned. I think there was a comment from the audience during one if the talks (maybe Fabien's) about a multi Kernel environment but I can't remember their scenario. |
Recently, I had a very slow dev environment due to some 3th party bundles with lots of templates. It made the twig cacher very slow and with that, also each request in dev. I don't know if this is a good practice though... |
Having a different kernel in prod and dev looks really weird to me. @kbond the common use case for multiple kernel IMO is having an API and a website in the same project. The API can use a separate kernel, allowing to avoid loading a bunch of bundles it does not need (related to the website stuff) and loading other bundles which should affect only the API (FOSRestBundle for instance) |
+1 for the example with a "website" (frontend) and an API. It works especially well since you can show how some API-related bundles don't need to be enabled for the "website" kernel. I don't think this entry needs to be huge - just highlight some directory structure stuff, show how you have different bundles registered (but you use some bundles on both), and why you would use this approach. |
…rnels (javiereguiluz) This PR was merged into the 2.7 branch. Discussion ---------- Added a new article about applications with multiple kernels This fixes #997 (opened in January 2012 !!!). --- 1) I don't know which is the best location for this article (probably not `request/`) 2) When merging up, in the 2.8 branch the following must be added: At the end of `Step 2)`, add this: ``` rst In order to make this class available in the front controller, don't forget to add it to the ``classmap`` configuration of the ``composer.json`` file: .. code-block:: json { "autoload": { "psr-4": { "": "src/" }, "classmap": ["app/AppKernel.php", "app/ApiKernel.php"] }, ... } ``` At the end of the article, add this: ``` rst .. tip: Symfony 2.8 introduced a `new micro kernel`_ PHP trait that simplifies the creation of kernels. You can even define them in a single PHP file. .. _`new micro kernel`: http://symfony.com/blog/new-in-symfony-2-8-symfony-as-a-microframework ``` Commits ------- bc3618d Made a bunch of fixes recommended by Ryan 2613810 Added a note about rendering templates from different kernels e403fd8 Added a new section about running commands under a different kernel af4ff18 Added a new use case related to micro-services 2c5aeb1 Removed a use case 097a73d Reworded the use cases section 5c8ed87 Fixed typo d45e1f4 Fixed an example code a23d82d Fixed another syntax issue 21329ec Fixed some syntax issues 7cb2aa1 Added a new article about applications with multiple kernels
Boom! |
this could be based on https://github.com/liip/sf2debpkg
The text was updated successfully, but these errors were encountered: