Cloud Platform

Configuration management for Drupal

This page describes the best ways to handle configuration management for websites running the current Drupal version on Cloud Platform.

Drupal’s configuration management (CM) makes major improvements to how the current Drupal version manages the configuration, compared to earlier Drupal versions.

Note

By default, websites running the current Drupal version use the sync configuration directory in your files directory. For example, docroot/sites/default/files. For more information, see Understanding files.

Acquia recommends you to store the configuration in a directory above the docroot in your repository.

Required config/default folder

For websites running the current Drupal version, Cloud Platform requires you to define a default location for the configuration directory where you store Drupal configuration information in your code repository. Typically, this directory is located at:

config/[sitename]

Here, config is a directory at the same level of your docroot directory. You must create the directory as it does not exist in the repository by default. If you do not create the config directory, Cloud Platform displays the following error message:

The directory docroot/../config/default does not exist.

You cannot run update.php until you create the config directory. Also, you cannot commit empty directories in Git.

In the new directory, you must also add the .gitkeep text file before you can commit the directory to your repository. After creating the directory, you have the following file structure at the docroot level:

/docroot/
config/default/

In the settings.php file for your application, define the following config path:

$settings['config_sync_directory'] = $app_root . '/../config/' . basename($site_path);

Site Factory subscribers must also create a post-settings-php hook as described in Configuration management directory.

Pushing the configuration

To understand the process of pushing the configuration, assume that you want to build or update an application named example that runs the current Drupal version in the Development environment in Cloud Platform. Acquia recommends you to use Acquia Cloud IDE or a local development environment as Cloud Platform is read-only.

To export and push the configuration:

  1. Export the configuration with the following command:

    drush config-export --uri=default

    The system displays the following message:

    [notice] The active configuration is identical to the configuration in the export directory (../config/default).
  2. Review the changes with the following command:

    git show
  3. Verify the changes before pushing them.
  4. If you are satisfied with the changes, push them with the following commands:

    git add --all
    git commit -m “export and push config”
    git push

    To push the changes, you can use Git or the push artifact.

  5. If you are not satisfied with the changes:
    1. Remove the changes:

      git reset --hard HEAD^1
      drush config-export --uri=default
    2. Adjust the changes and run the following commands:

      git add --all
      git commit -m “export new change and push config”
      drush config-export --uri=default 
      git push
  6. Sign in to the Cloud Platform user interface and select your application.
  7. Drag the code element from dev to stage to deploy your configuration from the development environment to the staging environment.
  8. Connect to your staging environment using SSH.
  9. Import the configuration from the file system to the database for the staging environment:

    drush config-import --uri=default
  10. To apply database updates, run update on your staging environment:

    drush updatedb --uri=default