WP-CFM: A Free Plugin for Storing and Deploying WordPress Database Configurations

WP-CFM is a new free tool for WordPress created by Matt Gibbs, author of the popular Custom Field Suite plugin. It provides configuration management for WordPress database changes, similar to Drupal’s Features module.

WP-CFM lets you create and store bundles, which are essentially a group of one or more configuration options. The first step after installing the plugin is to create a /wp-content/config/ directory and grant write access.

add-bundle

WP-CFM provides a friendly interface for viewing the contents of the wp_options table so that you can select the options you want to be stored in a specific bundle. For example, let’s say that you want to grab all of your Jetpack options for deploying somewhere else. Create a Jetpack bundle:

jetpack-bundle

Each bundle has options for diff, push and pull:

  • diff – comparison of database version vs the file version
  • push – write database changes to the file system
  • pull – import file changes in the database

Selecting ‘push’ will store the database configuration in the file system (wp-content/config) as a .json file that you can then pull into your database at a later time or pull into another server.

One very common example where WP-CFM would be helpful is in the case of widgets options. Step one is to create a widgets bundle:

widget-options

Next you would create a widgets diff:

widgets-diff

From here you can push those changes to the filesystem so they’re ready to deploy at another time. Most of the time when using WP-CFM, you’ll follow this basic workflow for storing and deploying configurations:

  1. Make database changes
  2. Store them in configuration management
  3. Push the file to another server

The ‘push’ option on the All Bundles item writes all of your bundles to the file system at once, which is fairly handy. WP-CFM also includes developer hooks for registering custom configuration items, including a callback parameter for configuration data that is not stored within wp_options.

Deploying bundles is really easy with WP-CFM’s support for WP-CLI, which enables you to pull or push bundles from the command line. Setting the bundle_name to “all” will push/pull all at once:

[php light=”true”]wp config pull <bundle_name>
wp config push <bundle_name>[/php]

Benefits of using WP-CFM

WP-CFM can save you quite a bit of time when working alone but it really shines when working with team of multiple developers. In the docs, Gibbs identifies the benefits of including it in your workflow:

  • Less need to copy the database. If you make changes, Push your bundle to the filesystem. To load changes, Pull the bundle into your database.
  • No need to manually apply database settings changes. No more “fire drills” where you’re rushing to figure out which settings you forgot to change.
  • Track and migrate configuration files using git, subversion, etc.

WP-CFM is an excellent new tool for simplifying deployments and the best part is that it’s totally free. You can download it from Github or via the plugin’s homepage.

3

3 responses to “WP-CFM: A Free Plugin for Storing and Deploying WordPress Database Configurations”

  1. This looks very useful. Usually I create a snapshot in Duplicator and copy the whole site over, but that takes at least a few minutes. With this plugin, copying just a couple of options from one install to the other should be easy.

    I will also check out the author’s custom fields plugin, which I hadn’t heard of before.

  2. but what for the other database tab? i read about this plugin:

    “WP-CFM will be handy if you assume all your configuration settings are in the options table, in very simple key value pairs.This assumption is risky, I’ve seen so many plugin developers build their plugin to save settings in all kinds of ways that I can’t safely assume that config will actually be in the options table.”

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.