Config in Code (CINC) takes a code-first approach to Drupal configuration. CINC has no web interface, and does not export configuration to code, like Features or Configuration Management does. Instead, CINC assumes you're writing code to manage configuration and makes that as easy as possible. For an experienced developer, writing config with CINC should be faster than using the browser interfaces, though CINC is also a good starting point for writing your own browser interfaces.

CINC is built on a "CRUD" design, so all configuration can be Created, Read, Updated, and Deleted. Currently CINC can manage configuration for Content types, Fields, Views, Webforms, Beans, Field groups, Image styles, Date formats, Menus, Nodequeues, Text filters, WYSIWYG profiles, and more.

The PHP interface looks a lot like the configuration API in Drupal 8, with additional functionality to make things even easier. For example CINC_ContentType's ->add_field() method takes a CINC_Field object so field instance creation can be automated. And CINC_View makes adding a random sort as simple as ->add_sort('random').

Example

<?php

/**
 * Implements hook_enable().
 */
function example_enable() {
  // Create a field
  $example_field = CINC::init('TextField')
    ->machine_name('field_example_field')
    ->set_instance('label', 'Example Field')
    ->create();
  // Create a content type with a field.
  CINC::init('ContentType')
    ->machine_name('example') // Display name is (optionally) auto-generated from type.
    ->set('title_label', 'Example Title')
    ->create()
    ->add_field($example_field);
  // Add a field to an existing content type.
  CINC::init('ContentType')
    ->machine_name('example_exists') // Tells CINC which content type this is.
    ->read()
    ->add_field($example_field); // Field instance is auto-created like this.
}

/**
 * Implements hook_disable().
 */
function example_disable() {
  // Delete what we created.
  CINC::init('TextField')->machine_name('field_example_field')->delete();
  CINC::init('ContentType')->machine_name('example')->delete();
}

?>

CINC YAML

The CINC YAML submodule allows configuration to be read directly from YAML files, just as they are in Drupal 8. This makes most configuration easily reusable between Drupal 8 and Drupal 7. This submodule currently requires the PHP YAML extension.

CINC YAML Export

The CINC YAML Export submodule is a work in progress, a browser-based UI for exporting config to YAML files, which CINC YAML (or Drupal 8) can read.

Drupal 8 Plans

While CINC reproduces much of Drupal 8's configuration API in Drupal 7, it also adds useful functionality on top of that, so a Drupal 8 port will be created eventually. That's about as far as the plans go so far.

Get Involved

It's easy to add new CINC integrations for configuration not yet covered. Patches are welcome, but any module can also provide its own CINC implementations simply by subclassing CINC with a class name that starts with "CINC_", which CINC will automatically pick up. If you need any help using CINC, just open a support issue.

Supporting organizations: 

Project Information

Downloads