Score:1

How does the config sync directory work exactly?

co flag

I just had a question quick about how Drupal's config sync works. I work on a large Drupal site where I am having some coworkers joining in on working on the project. It's a version controlled site where we develop locally on Docker and then pull changes to a web server.

I recently discovered that Drupal has a "config synchronization" feature. If making changes to the site (be it views, blocks, etc.), a user can go to this page, export their configuration into a tar file, and import into their local setup (or vise versa, from dev to prod).

That much I have learned and is one way to sync Drupal environments. But I am confused as to how the config sync directory comes into play (the one with the UUID of the site that gets stored into the files directory by default). On a local dev environment on a test branch, I relocated this folder, version controlled it, and changed the settings.php to point to this new location. I noticed, when I make changes to anything (say a view), the config sync folder has no changes shown. If I go to the config sync screen, I then see this message:

The following items in your active configuration have changes since the last import that may be lost on the next import.
views.view.test_config_view

I'm very confused what the purpose of the config sync folder is. Is it not supposed to update somehow when changes are made to a Drupal site? I tried clearing the cache and everything. I thought this would be the correct way to synchronize changes with multiple people working on the site (instead of using the import/export screen and creating tar files). I'm also confused as to why it's forcing me to synchronize to the last import done, even if mine has more recent edits. Thank you for anyone who can better explain this to me.

leymannx avatar
ne flag
In Drupal, configuration is the collection of admin settings that determine how the site functions, as opposed to the content of the site. Configuration will typically include things such as the site name, the content types and fields, taxonomy vocabularies, views and so on. https://www.drupal.org/docs/configuration-management
Kevin avatar
in flag
You have to export new changes. It isn't automatic.
leymannx avatar
ne flag
Let's say you set up a copy of a live site on your computer. Code, database, local site is running. Now on the local site you develop a new feature. Like creating a new content type with lots of fields. How do you get these changes to your live site now? You export your local config. And then import it on your live site again. Voila, new content type with lots of fields is now live. That's an extremely short version of actually having a Git repo to move new features from local to live. You normally use Drush for exporting and importing config. But you could also go with moving the Tarball.
leymannx avatar
ne flag
It is recommended that you have your config sync directory outside of the web root. And then adjust the settings.php to point to the new location.
Jaypan avatar
de flag
I wrote a series of tutorials that may help you understand better: https://www.morpht.com/blog/drupal-8-configuration-part-1-configuration-api
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.