HomeDrupalCode-driven Content in Drupal Development

Code-driven Content in Drupal Development

Here at NEWMEDIA we use a 100% code-driven development model, and a new website’s initial content is no exception.

Code-driven content?

Yes. We take a code-based approach to initial content in our sites as well. Basically, we define content in code as part of our install profile for the site and inject it into the site on site-install. We do this for the following reasons:

  • Testing content and test users are available at all stages of a site’s development.
  • No need to share the database with other developers. Since the content is in code, everyone is up to date.
  • New content or changes to testing or initial production content is all tracked in git.
  • We can deliver a site, sans-database, with initial production content already in place (“About Us,” “Terms of Service,” initial product offerings, store locations, etc.).
  • Early in development we can define test users in each role on the site so that at any point in development or QA we can easily log in as one of these test users and quickly gauge the user’s authenticated experience. No wasting time with devel generate or setting up testing scenarios time and time again.

How?

After much research we settled on the migrate module. This allows us to define migrations for content types, product types, taxonomy vocabularies, etc. as we create them in the site. We then use our installation profile to kick off the migrations on site-install.

The end result

Developers can collaborate on new projects without worrying about the database. The entire site is held in code. Features and functionality can be demonstrated and tested on site-install, on every developer’s instance of the site, as the content that powers these features is immediately available. And finally, because this content is only version-controlled in the context of a site install, once the site is launched and content begins to change, the site’s repository and features remain in a default state.