99 votes

How can I import the configuration on a different site?

Youu can get the UUID with drush config-get "system.site" uuid. You can change it with drush config-set "system.site" uuid [uuid].
Gucho Ca's user avatar
  • 1,125
34 votes

How do I remove a configuration object from the active configuration?

Drush command to delete configuration object: drush config-delete <config_name>.
ya.teck's user avatar
  • 5,632
32 votes

Import a single yml configuration file

You can use $ drush cim --partial --source=only-few-configs/ Your help says: $ drush cim --help Import config from a config directory. Examples: drush config-import --partial Import ...
rpayanm's user avatar
  • 3,601
25 votes

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

Solved! Method 1: Go to the admin/reports/status and find the field machine name. For Example: "paragraph.field_video_upload". Edit the field storage settings and save the configuration ...
Thirsty Six's user avatar
22 votes

Import a single yml configuration file

You can import one configuration by running the following command: drupal config:import:single If you are trying to run multiple import you can create a chain for that. Command Documentation - ...
itsdarrylnorris's user avatar
19 votes
Accepted

How can I import the configuration on a different site?

Using Drupal Console You can override your current site's UUID with the value present in the configuration you want to import. You can achieve this with Drupal Console by overriding the uuid key for ...
MrUpsidown's user avatar
19 votes

How do I update the configuration of a module?

I've found this Gist on GitHub, which reverts/reloads given module's configuration using drush: drush cim -y --partial --source=modules/path/to/module/config/install/
Elin Y.'s user avatar
  • 7,349
18 votes

How to prevent Devel module to be installed on production environments

Method: Drush Drush can ignore the enabled states of extensions when synchronizing configuration. drush cex --skip-modules=devel drush cim --skip-modules=devel With Drush CMI tools you can operate ...
Adrian Cid Almaguer's user avatar
18 votes

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

drush entity-updates (aka drush entup) has been deprecated as of Drupal 8.7.0. You either need to write an update script using hook_update_N(), or you can use the Devel Entity Updates module, which ...
Jaypan's user avatar
  • 17.6k
16 votes

How to load field configurations in code

The terminology is a bit confusing (as usual with Drupal), but here goes: Field storage configurations are defined by FieldStorageConfig. To load one, do this: $field = Drupal::entityTypeManager()-&...
rudolfbyker's user avatar
15 votes

How can I exclude configuration from import/export?

You can use the "Config Ignore" module: https://www.drupal.org/project/config_ignore Ever experienced that your site's configuration was overridden by the configuration on the filesystem, ...
Weri's user avatar
  • 311
14 votes

How do I update the configuration of a module?

As I landed on this question as well but did not really find the correct answer for my situation here, I'd like to add another answer. Please note: Anti-pattern ahead! Use case When we're ...
Ambidex's user avatar
  • 909
14 votes
Accepted

How can I retrieve the value of a configuration object from a template?

The values saved as configuration items can be accessed using code similar to the following one. $slogan = \Drupal::config('system.site')->get('slogan'); Since you are asking for a template file, ...
apaderno's user avatar
  • 97.5k
14 votes
Accepted

YML For Enabling a Contrib Module

To enable a module, you just need a line in core.extension.yml. However, you also need all the configuration the module provides. You could copy that over yourself from the config install and optional ...
Berdir's user avatar
  • 83.2k
14 votes
Accepted

Manage config translations programmatically

The answer from @Smartsheet eng is correct if you want to load and read a specific translation as a config entity, see also How to progragrammatically get NodeType translated value in D8?. However, ...
Berdir's user avatar
  • 83.2k
14 votes
Accepted

Best Way to Handle Variables Per Environment

You can create a new setting in your settings.local.php or settings.php file like: $settings['event_base_url'] = 'https://www.example.com'; or some people are adding switch block based on the server ...
kenorb's user avatar
  • 14.2k
13 votes

Site UUID in source storage does not match the target storage

Traditionally, you would use the following before importing config: drush cset system.site uuid "6ba9bxxx-xxxx-438x-9c8x-e5x7x3d0x347" Or with drupal console: $ drupal config:override Enter ...
Stef Van Looveren's user avatar
13 votes
Accepted

Attempt to create a field body that does not exist on entity type node

You attempted to create a field using configuration without creating the field storage configuration. In the field configuration YAML you can see a field_storage property. That is the id of the field ...
Eyal's user avatar
  • 3,266
12 votes

What does "The provided host name is not valid for this server" mean?

This happens because trusted_host_patterns variable in your settings file. If you're working on the local environment and you want to override this, define the following section in your settings.local....
12 votes

Site UUID in source storage does not match the target storage

You can fix this by changing your local site UUID, with Drush, as described in one of the answers for How can I import the configuration on a different site? I also needed to run a mix of drush entity-...
oknate's user avatar
  • 14.3k
12 votes
Accepted

When to use mapping or sequence to define an array in a schema file?

A sequence is an unlimited list of identically structured elements. A mapping is a limited set of keys, each key has a possibly different structure. Your key has node types, so you're storing a list ...
Berdir's user avatar
  • 83.2k
12 votes
Accepted

How can I programatically change the (D8 core) workflow state of an entity with Content Moderation?

A great example could be found in Content Moderation module's code. $entity->set('moderation_state', $new_state); if ($entity instanceof RevisionLogInterface) { $entity->setRevisionLogMessage(...
Dmytro Danylevskyi's user avatar
11 votes

How can I import the configuration on a different site?

You can get the site UUID without access to the site or database. If you don't have access to the original site/database, you can still sync from provided config files. The config will contain your ...
Atomox's user avatar
  • 327
11 votes
Accepted

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

You can solve this issue by two ways. If you installed Drush, you can run drush entity-updates. Otherwise, add the following lines in the index.php file located in the Drupal root folder, before $...
Rahul's user avatar
  • 328
11 votes

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

Find the field in /admin/reports/fields. For each entity that uses the field, edit the field and save the parameters again. This should be updating the database and make the entity and the field match ...
Matoeil's user avatar
  • 3,429
10 votes

How do I remove a configuration object from the active configuration?

Using the drupal console: $ drupal config:delete 'the_config_to_delete'
VincentLalieu's user avatar
10 votes

How can I exclude configuration from import/export?

You can use a combination of config_ignore and config_split for this. Config ignore allows you to ignore a subset of configuration entities during import (also prevents deletes since the 2.x release)....
Geert van Dort's user avatar
10 votes

Drupal 8 variable_get

The accepted answer is half the answer. As marcvangend notes, there are two options in Drupal 8 for what used to be stored in the variables table and was stored and retrieved with variable_set() and ...
mlncn's user avatar
  • 1,482
10 votes

Exporting fields for content type

UPDATE You might also try Drupal Console's drupal config:export:content:type command. It's description says: The config:export:content:type command Export a specific content type and their ...
otarza's user avatar
  • 954

Only top scored, non community-wiki answers of a minimum length are eligible