Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reviewed

Note that things vary when managing different configurations per environment. See D8 This article covers config split in a very cursory fashion. For more detail see Configuration Split.

Setup

  1. Make sure your settings.php defines the sync directory at sites/default/config. This can look like the following:

    Code Blockif ($is_installer_url) { $config_directories = array( CONFIG_SYNC_DIRECTORY => 'sites/default/files', ); } else { $config_directories = array( CONFIG_SYNC_DIRECTORY => 'sites/default/config', ); }

    . Put it in the Drupal install directory unless you have a good reason to do otherwise.

    Code Block
    languagephp
    /**
     * Place the config directory outside of the Drupal root.
     */
    $settings['config_sync_directory'] = dirname(DRUPAL_ROOT) . '/config/sync';

  2. Export all the configuration from your site (using Saving Config Changessee steps 3-5 below), and commit it to sites/default/your config directory.

Saving Config Changes

When you want to push up new database setting changes collaboratively, do the following:

...

  1. Example: Modify permissions

...

  1. git checkout -b feature/yourname/kblog-2--permissions

...

You can export config via the admin interface or by using drush.  In most cases, it is more efficient to use drush.

Exporting config changes for a Pull Request

Via the Admin InterfaceUsing Drush
1Make database changes (e.g. change permissions)
2Create a new feature branch 
git checkout -b feature-branch-name
3Visit /admin/config/development/configuration/full/export

...

and click "Export"

drush config-export

AKA

drush cex

4Uncompress the .tar.gz file system downloaded, and copy the config to your config directorydrush already exported the files where they need to go
5If any of your changes are covered by config split, visit /admin/config/development/configuration/config-split and export the required configdrush exports config splits at the same time
6Add the config changes needed for your PR.  Do not check in changes unrelated to your feature.  i.e. 
git add permissions.yml

...


7commit your changes 
git

...

commit

...

-m

...

"

...

Update

...

author permissions to enable something"
8Push

...

your changes

...


git

...

push origin feature-branch-name
9Open a pull request from your feature branch

Loading Config Changes

When You'll want to import new config changes to the database when you bring down new config changes through git, you'll want to import them to the database. To do this:

  1. Bring git pull the changes down
  2. git pull
  3. into your repo
  4. Import the configs
    1. Visit adminVisit /admin/config/development/configuration /full/import and click Import All

Notes

...

    1. or run drush config-import

...

Have configuration directories outside of webroot.

Commit to config/staging.

Use drush config-import to import from staging to your Sync directory.

...

    1. AKA drush cim
  1. If using the admin interface, and importing configuration covered by config split, visit /admin/config/development/configuration/config-split click the dropdown to the right of your active environment, click Import, and then Import All.