Drupal7: Configuration Module

David G - DrupalThroughout my Drupal development learning curve I’ve attempted to streamline how I create and manage Drupal configuration with my project source code repository (such as Git). From Drupal 5 to Drupal 6 to Drupal 7 my approach to website development has changed slightly.

In the past I’ve used database dumps (eewww), I’ve used Features (ehhh) and lately I’ve been creating Installation Profiles and leveraging Features, Bash and drupal update-N hooks. A sore point to these approaches is the more code you generate by hand to build a website — the harder it becomes to maintain and the site itself can become more brittle if you’re not careful with how you’re building it. Now enters a new solution into this development process (which is also essentially a key component to Drupal 8).

A downside of Features for example is that a Feature owns a particular set of configuration. If you make a new content type and export it into a Feature and install it onto a website the owner module in the system table is not node but feature. Want to remove the feature module dependency from your content type and website — good luck, it’s possible but it gets technical and messy. Features as a storage mechanism for configuration is actually a side-effect of Features original design; to create re-usable site components.

Enter the Configuration module for Drupal 7. This module attempts to mimic the Drupal 8 configuration import/export API created for Drupal Core. By learning how to use this module you’re 1 step closer to being more comfortable and familiar with a new mechanism of Drupal 8.

By using the Configuration module, anything in Drupal that is exportable via the Ctools API is exportable to simple files which can be tracked via version control, migrated between website instances. This is similar to Features, but all the files go into a single directory of your webserver and the configuration is not owned by any 1 module.

When you install the configuration module (eg using drush dl configuration -y; drush en configuration -y;) you may select what directory the configuration files reside in:

Configuration module Settings admin page, you may override the default filestore location here.

Configuration module Settings admin page, you may override the default filestore location here.

In the above image you’ll also see some additional administrative tabs for the Configuration module. In addition to the Settings tab the configuration actions include:

  • Tracking: This page shows you what drupal items your configuration is currently tracking (fields, variables, wysiwyg profiles — any ctools exportables you’ve opted to Track). Whether or not their filestore value and live database values are in sync is displayed to you:
    config-trackingIn red above you’ll see the 1 content type I am tracking (unchanged between the database configuration and the filestore configuration) and also 2 items that are being tracked but have changed since they were exported to configuration).
  • Not Tracking: This page lists only items your configuration is not tracking. If you need to begin tracking a new piece of configuration (like say a new View you’ve created) you would look here.
    config-not-trackingIn the above image you’ll note that I do not track about 11 drupal content types. At this time I simply do not need to be tracking them.
  • Synchronize: This action allows you to import or enforce all the tracked configuration files in your tracked.inc file from all the values in your datastore directory. Let me put that another way — this is the same thing as a Features Revert command in Features.
  • Migrate: Gives you the options to select any configuration values and Export to Tar Ball. This can be useful if you want to manually move some configuration files from 1 system to another (it has Export and Import local actions).

An example of the filestore directory contents for an in-progress project:

# This shows FILENAME followed by FILESIZE in either bytes or kilobytes.
/var/www/2014/MYPROJECT/config > ls -lah | awk '{print $9, $5}' 
. 4.0K
.. 4.0K
content_type.campus_highlight.inc 1.7K
context.admin_pages.inc 1.3K
context.public_sitewide.inc 2.2K
field.node.field_campus_highlight_image.campus_highlight.inc 4.3K
field.node.field_highlight_assignments.campus_highlight.inc 2.9K
field.node.field_highlight_serial.campus_highlight.inc 2.3K
.htaccess 491
linkit_profiles.complit_d7_linkit.inc 2.5K
menu.secondary_menu.inc 401
permission.create_campus_highlight_content.inc 340
permission.delete_any_campus_highlight_content.inc 348
permission.delete_own_campus_highlight_content.inc 348
permission.edit_any_campus_highlight_content.inc 344
permission.edit_own_campus_highlight_content.inc 344
permission.use_text_format_1.inc 363
permission.use_text_format_2.inc 336
text_format.1.inc 1.3K
text_format.2.inc 989
tracked.inc 6.9K
variable.additional_settings__active_tab_campus_highlight.inc 295
variable.admin_theme.inc 211
variable.ant_campus_highlight.inc 221
variable.ant_highlight_image.inc 219
variable.ant_pattern_campus_highlight.inc 282
variable.ant_pattern_highlight_image.inc 261
variable.ant_php_campus_highlight.inc 227
variable.ant_php_highlight_image.inc 225
variable.auto_nodetitle_php_highlight_image.inc 248
variable.comment_controls_highlight_image.inc 245
variable.comment_default_mode_highlight_image.inc 251
variable.comment_default_order_highlight_image.inc 255
variable.comment_default_per_page_highlight_image.inc 262
variable.comment_form_location_highlight_image.inc 255
variable.comment_highlight_image.inc 227
variable.comment_preview_highlight_image.inc 241
variable.comment_subject_field_highlight_image.inc 255
variable.content_extra_weights_highlight_image.inc 453
variable.edit_node_admin_theme.inc 223
variable.field_bundle_settings_node__campus_highlight.inc 604
variable.form_build_id_highlight_image.inc 275
variable.menu_options_campus_highlight.inc 243
variable.menu_parent_campus_highlight.inc 247
variable.menu_secondary_links_source.inc 248
variable.node_options_campus_highlight.inc 286
variable.node_options_highlight_image.inc 263
variable.node_preview_campus_highlight.inc 239
variable.node_preview_highlight_image.inc 235
variable.node_submitted_campus_highlight.inc 241
variable.node_submitted_highlight_image.inc 239
variable.pathauto_node_highlight_image_pattern.inc 254
variable.redirect_setting_name_campus_highlight.inc 272
variable.rh_module_campus_highlight.inc 239
variable.rh_node_action_campus_highlight.inc 243
variable.rh_node_override_campus_highlight.inc 245
variable.rh_node_redirect_campus_highlight.inc 246
variable.rh_node_redirect_response_campus_highlight.inc 267
variable.save_continue_campus_highlight.inc 259
variable.skinr_settings_highlight_image.inc 297
variable.teaser_length_highlight_image.inc 239
variable.theme_complit2014_files_directory.inc 286
variable.theme_complit2014_settings.inc 22K
variable.upload_highlight_image.inc 225
views_view.archive.inc 4.9K
views_view.campus_highlight_shot.inc 6.3K
views_view.complit_faculty_vbo.inc 16K
views_view.faculty_listing.inc 18K
views_view.frontpage.inc 3.7K
views_view.glossary.inc 6.0K
views_view.grad_students.inc 9.7K
views_view.graduates_vbo.inc 11K
views_view.news_and_events.inc 12K
views_view.newsletters.inc 4.1K
views_view.nodequeue_1.inc 6.0K
views_view.redirects.inc 7.5K
views_view.taxonomy_term.inc 5.2K
views_view.uploaded_attachments.inc 5.0K
wysiwyg.1.inc 200
wysiwyg.2.inc 200

As you can see the Configuration module looks like a great tool if you were starting to create a Drupal 7 website and hoping to migrate it easily to Drupal 8 in the future. It provides a wealth of flexibility without adding odd dependencies into your project.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under Drupal, Drush | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *