98 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,115
58 votes

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

The easiest way to do this at the moment is to use drush php (or core-cli) to open an interactive session. Then use: Drupal::configFactory()->getEditable('system.menu.devel')->delete(); This ...
lexicant's user avatar
  • 751
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,594
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,581
22 votes
Accepted

Drupal 8 variable_get

In Drupal 7 $data = variable_get('test_content_types'); In Drupal 8 $data = \Drupal::state()->get('test_content_types'); For more information about about "get", "set", "delete" visit - Step ...
itsdarrylnorris'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
21 votes

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

Solved! 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 again. That's ...
Thirsty Six's user avatar
18 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
18 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/
Елин Й.'s user avatar
  • 7,309
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
17 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.3k
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
15 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
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
  • 879
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
  • 82.9k
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
  • 82.9k
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.1k
13 votes
Accepted

What order should configuration import and module updates be run?

Updates must be run before configuration is imported A pending issue against core will ensure that the code and schema versions match before allowing configuration to be imported. Problems with ...
gapple's user avatar
  • 1,554
13 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
  • 97k
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,246
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
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
  • 330
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.1k
12 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
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
  • 82.9k
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

config-import error: These entities need to be deleted before importing

For: Entities exist of type Shortcut link and Default. These entities need to be deleted before importing. You need delete the entities of type short-cut, you can do with drush: drush ev '\...
Edys Meza's user avatar
  • 121
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,369
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

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