Skip to content

Instantly share code, notes, and snippets.

@abidkhan484
Last active January 11, 2024 06:08
Show Gist options
  • Save abidkhan484/52046e67b34f437c6308fe0d6496503a to your computer and use it in GitHub Desktop.
Save abidkhan484/52046e67b34f437c6308fe0d6496503a to your computer and use it in GitHub Desktop.
Sync Configuration Drupal 9 using commandline

Sync Configuration Drupal 9 using commandline

A short handnote to sync configuration between different environments like local, dev, staging or production using Drupal and Drush commands.

Export configuration

To export using drupal command

./vendor/bin/drupal config:export:entity \
  paragraphs_type [MACHINE_NAME_OF_PARAGRAPH_TYPE] \
  --module="[YOUR_MODULE]" \
  --optional-config \
  --remove-uuid \
  --remove-config-hash \
  --include-module-dependencies

Sample

./vendor/bin/drupal config:export:entity \
  paragraphs_type machine_name_of_paragraph \
  --module="$MODULE_NAME" \
  --optional-config \
  --remove-uuid \
  --remove-config-hash \
  --include-module-dependencies

Import configuration

To import using drush command

./vendor/bin/drush cim --partial \
  --source=$PATH_OF_THE_CONFIG_DIRECTORY

Sample

./vendor/bin/drush cim --partial \
  --source=$PWD/web/modules/custom/$MODULE_NAME/config/optional/

Conclusion

Similarly, content_type or paragraphs_type can be export with updating the below flag in the above command.

Entity Type Command Type
content_type node_type
paragraphs_type paragraphs_type

$\color{red}{Note}$: Till now difficulty is to export taxonomy. Or the others I didn't try.

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment