Problem/Motivation
#2309575: [Revert] Remove the null and memory backend definitions from core.services.yml in favour of devel module providing them instead already has some kickback, and there is not a patch for devel yet. People want to be able to easily use these backends, especially to disable render caching.
Proposed resolution
Introduce a services.local.yml file that can easily be enabled. This will then get added to the service yaml files when the container is being built.
This also serves as a good example usage for the 'container_yamls' functionality, for which there is currently nothing anywhere. You would only know it existed by reading the code in DrupalKernel.
Remaining tasks
User interface changes
None
API changes
None, just development/local workflow changes.
Comments
Comment #1
damiankloip commentedAnd a quick patch..
Comment #2
damiankloip commentedComment #3
dawehnerCan we add a @todo to use imports in services.yml in the future? In that case you would need to adapt the settings
indentation needs one more space, sorry
Comment #5
damiankloip commentedFixed the intentation, let's see how these other issues progress and not do the todo. We will not forget.
Comment #6
damiankloip commentedComment #7
dawehnerThank you! Adding all the tags.
Comment #9
alexpottLet's add the example for how to disable render cache to example.services.local.yml - I think we can do this by overriding cache.render cache factory (not sure about that)
Comment #10
dawehnerThe "configuration" could be moved properly from Settings() to the yml file once #2315613: Add a development.services.yml for development is in.
Comment #11
damiankloip commentedAmended comment in example local settings file. Correct branch helps too.
Comment #12
dawehnershouldn't this mention rather settings.local.php ?
Comment #13
joelpittetI've got a stupid question but if we move /sites/example.settings.local.php to /sites/default/settings.local.php. Will leaving the services.local.yml still work from /sites/? *haven't checked what's in $conf_path*
I've been moving those files by habit but maybe I don't even need to do that anymore?
Comment #14
tim.plunkettTempted to bump this to critical. I have no way to turn off render caching right now, which pretty much stops all dev work in its tracks.
Comment #15
damiankloip commentedYep, over zealous with the renaming. Here is that change.
Comment #16
damiankloip commentedWhoops. Proper patch.
Comment #17
damiankloip commentedOh dear. We want an updated settings.local file too. SORRY FOR THE NOISE.
@joelittet: You can just put in any path you want really? Hardcore the example files if you like :)
Comment #18
tim.plunkettservices.local or local.services?
Won't this break if the local.services.yml is missing?
Comment #19
dawehnerLet's put that into the if() as well?
Comment #20
damiankloip commentedI am fine adding it in there. As long as people are OK with silent failures. This will just suppress any warnings you will get for the service not being available.
Comment #23
joelpittetIt will fail being in the if() as well as being outside if the local.services.yml/services.local.yml doesn't have that null backend definition. (unlikely but still possible I think.)
I was thinking about mentioning that one too. Though I'd like to know there is something wrong and not fail silent, how about yous?
Comment #24
damiankloip commentedYes. Someone could remove that definition from that file I guess.. As I was saying before and you have agreed with, I would rather see any errors for sure :)
Comment #26
damiankloip commentedFixed file naming.
Comment #27
jibranisn't it similar to #2241633: Simplify site-specific service overrides?
Comment #28
jibranThere is also #2244807: Replace $GLOBALS['conf']['container_yamls'] with optional $conf_path/services.$env.yml file
Comment #29
jibranAnd this issue is also doing something with services.yml #2241581: Simplify site-specific (development) active/runtime config storage
Comment #30
damiankloip commentedCode from #2241633: Simplify site-specific service overrides is already in. #2244807: Replace $GLOBALS['conf']['container_yamls'] with optional $conf_path/services.$env.yml file I am not as sure about. I like the idea but I am not sure if I like the restriction. Plus, that just replaces the current
. I think we should keep the container_yamls functionality but use settings like this patch changes to (as using just $conf will no longer work).
Comment #31
wim leersI'd written this review yesterday, but I didn't notice posting it failed:
#2309575: [Revert] Remove the null and memory backend definitions from core.services.yml in favour of devel module providing them instead was reverted. I think it makes sense to recommit it as part of this patch, since this patch provides the solution.
Because #2309575 was reverted, #26 no longer applies. Rerolled, included the changes from #2309575 in this patch, and fixed my own nitpicks.
Comment #32
dawehnerNice, though can we please drop the memory and null backend again from the main container?
Next issues we need: #2251113: Use container parameters instead of settings #2284787: Allow yml files to nominate imports
Comment #33
wim leers#32: Oh, OOPS! Great catch.
Thanks for linking to those next issues!
Comment #34
dawehnergtg now. More to be done in the other issues.
Comment #35
alexpottSo to disable render cache all one would need to do would be to paste
into your current settings.php file?
Comment #36
wim leers#35: Yes.
Comment #37
fabianx commentedI disagree with the approach of providing a settings.local.php that needs work.
and #35 makes clear why:
This should just be available in core as
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.local.yml';
On the other hand this would belong to devel, but can devel add new services directly?
I am still in favor of providing DX config files per default that devel can extend instead of pushing all devel things to contrib.
Leaving RTBC as others might feel differently.
EDIT:
I think this is a case of "eating own dogfood". Every core developer will have something like that, which means any developer depends on devel, etc. or needs to follow this setup. I think the setup should be as simple as possible to get up and running for -dev.
Every time I come back to core dev the setup is a little different and new things are to change ...
Comment #38
wim leers#37: It's not entirely clear to me what you're saying. The recommended way is by using
example.settings.local.php— the instructions for that can be found at https://www.drupal.org/node/2259531, and it's been that way for 3 months now. #35 is an alternative way to do it.Can you clarify what you dislike and how you think it should work?
Comment #39
fabianx commented#38: I dislike that now I can't just plug in the settings.local.php, but that I have to:
- copy settings.local.yml as well
or I probably get WSOD.
That means I can't just copy the one file and am set, but I need to read the example.settings.local.yml and I need to copy two files now instead of one, where all I want is to have some development services, which could be living in a non-changeable file in core.
The example file could still be there, but do we really need to make the copying mandatory?
Comment #40
wim leers#39: Thanks for the clarification. I agree with that, I also raised that concern in #31.
You're suggesting to reduce the work to copying one file (
example.settings.local.php), and letting that file refer to/sites/example.settings.local.yml? I'd be fine with that.Comment #41
wim leersWhat do others think?
Comment #42
fabianx commentedI think I would leave the example file, but provide a development.services.yml file somewhere in core/ that can be referenced always.
Not sure its a good idea to reference to a example file ...
Comment #43
damiankloip commentedYes, linking to an example file is not a good idea. I am good with using a core development file.
I'm not sure we even need to bother with the example services file? I have just moved it for now.
Comment #44
catchPrefer it this way as well.
Comment #45
wim leersYes, much better! Thanks, damiankloip :) I'm glad #33 didn't get committed — #43 makes much more sense.
Comment #46
star-szr+1, was just going to RTBC. The end result is great, the only thing I can think to suggest is to move the line declaring the container yml closer to the line disabling the render cache but that's very minor.
Comment #47
damiankloip commented@Cottser that's how it was post #31 :) I like this approach too I think.
Thanks all.
Comment #48
catchCommitted/pushed to 8.x, thanks!
Comment #51
wim leersUpdated the change notice at https://www.drupal.org/node/2259531 to list the DX improvements added here.
Comment #52
wim leersI warned in #31:
Consequently, we now have #2348219: You have requested a non-existent service "cache.backend.null".
Comment #53
mikeker commentedUpdated the title to reflect what was actually added -- this kept tripping me up when I saw this issue linked in other issues and in the CR.
Comment #54
corbacho commentedAny thoughts on this one? #2723261: Ignore local development files in example.gitignore