View on GitHub

WP-CFM

WordPress Configuration Management

Download this project as a .zip file Download this project as a tar.gz file

WP-CFM: Configuration Management for WordPress

Download on WordPress.org

Deploying database changes in WordPress is hard, especially when working on teams with multiple developers. This project aims at solving this problem by storing database configuration in the filesystem. It's like Drupal's "Features" module for WordPress.

Admin Screen

Watch the introduction screencast (4 minutes)

What does this mean for me?

Terminology

Developer Hooks

The wpcfm_configuration_items hook lets you register custom configuration items.

function my_configuration_items( $items ) {
    $items['cfs_field_groups'] = array(
        'value' => 'MY CONFIGURATION DATA',
        'group' => 'WP Options', // optional
        'callback' => 'my_pull_handler', // optional
    );
    return $items;
}
add_filter( 'wpcfm_configuration_items', 'my_configuration_items' );

This filter contains an associative array of all configuration options. Each option has a unique key, and supports several parameters:

Is that it?

Almost! WP-CFM automatically handles configuration within the wp_options table. If your plugin stores settings elsewhere, then use the above callback parameter to tell WP-CFM how to properly import (Pull) configuration into the database.

/**
 * $params['name']          The option name
 * $params['group']         The option group
 * $params['old_value']     The current DB value that will get overwritten
 * $params['new_value']     The new DB value
 */
function my_pull_handler( $params ) {
    // Save something
}

WP-CLI

WP-CFM supports pulling / pushing bundles from the command-line using WP-CLI:

wp config pull <bundle_name>
wp config push <bundle_name>

You can optionally set bundle_name to "all" to push / pull all bundles at once.