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.
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:
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).
Review the changes with the following command:
git show
- Verify the changes before pushing them.
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.
- If you are not satisfied with the changes:
Remove the changes:
git reset --hard HEAD^1 drush config-export --uri=default
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
- Sign in to the Cloud Platform user interface and select your application.
- Drag the code element from
dev
tostage
to deploy your configuration from the development environment to the staging environment. - Connect to your staging environment using SSH.
Import the configuration from the file system to the database for the staging environment:
drush config-import --uri=default
To apply database updates, run
update
on your staging environment:drush updatedb --uri=default