Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By xpersonas on
When I install a new module, I run...
composer require drupal/module_name
That works. But it always overwrites this part of my development.services.yml...
parameters:
twig.config:
debug: true
auto_reload: true
cache: false
Do I need to have that info somewhere else? Am I doing something wrong?
Comments
Man, I too want to know the
Man, I too want to know the answer to this question. Sorry to see this was never answered.
This is due to drupal-scaffold
The
drupal-scaffold
that comes with thedrupal-composer/drupal-project
starter includes this file in its scaffolding scripts, so it gets written every time youcomposer-install
or something of the sort.I was able to fix this by adding the path to the "excludes" section like so:
Now, it no longer overwrites that file.
Hope that helps!
-Brian Lewis-
@ModsUnraveled
ModulesUnraveled.com
Minimum Solution
Just to stop overwriting that single file, all you need to add into the extras section is this:
FWIW, the exclude key worked
FWIW, the exclude key worked for a while, but no longer works for me. This is what I have now and seems to be doing the trick...
This worked for me with the
This worked for me with the drupal/recommended-project composer project.
You can confirm this works when running composer update /install and it should print out the following -
Scaffolding files for drupal/recommended-project:
- Skip [web-root]/sites/development.services.yml: disabled
Are you using the new
Are you using the new recommended project Drupal composer project? The above still works for me for composer/drupal-project.
Yes I believe so...
Yes I believe so...
Ok, good so now we have
Ok, good so now we have instructions for how to do it on the Drupal core recommended composer project, and on the previously commonly used setup.
Suggest to remove scaffold plugin
after initial use. It doesn't do the right things as you discovered. Unfortunately, the right thing is not a universal truth. It is depending on your circumstances what needs to be done. Rather than doing the wrong things most of the time, it should inform you that you need to do something. Currently, you need to detect that yourself.
For each of the files involved in scaffolding you need to determine your own version control. You need to decide what to do when changes occur. For some of those files it is fine to blindly accept the changes. For others you need to combine yours with their changes. Still others require you to apply changes to files based on that file.
Simply ignoring the changes for that file is just as bad as simply accepting the changes. Essentially, you need to be informed about the change and decide what to do. And you are the only one that can determine the right thing to do.
Agreed,I think the
Agreed,I think the scaffolding in the core project does a lot more that I don’t like than the old composer project, but I’d rather it all only run once, or produce output telling you where to look to figure out how to turn those things off. I think that conversation is actively happening for the core project.
Prefer the new scaffold over the old ...
because the files are now also part of core. Makes it easier to do the things properly. Allowing for three way merge.
Change file name in your settings.local.php
Renaming the development.services.yml file in your settings.local.php should do the trick. I would not exclude the file completely, since it will be missing if the project is installed elsewhere.
Simple solution
This worked for me and seemed less likely to cause issues later. Thanks all for the solutions; I tried a few before settling on @borutpiletic's