CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Exporting configuration to code [Solved]
Pages: [1]

Author Topic: Exporting configuration to code [Solved]  (Read 323 times)

John.K

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 5
  • CiviCRM version: 4.x
  • CMS version: Drupal 7
  • MySQL version: 5.x
  • PHP version: 5
Exporting configuration to code [Solved]
October 24, 2014, 07:34:10 am
Hi, I was wondering if there is a way of exporting CiviCRM configuration (custom fieldsets for example) to code, so that it can easily be moved between staging and live environments?

I had a quick search but couldn't find anything?
« Last Edit: October 24, 2014, 08:05:35 am by .John »

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Exporting configuration to code
October 24, 2014, 07:46:00 am
There's three options available last I checked:
Hmm, scratch that.  Looks like https://www.drupal.org/project/features_civicrm has been abandoned.

One option: Use CiviConfigure to export settings (https://civicrm.org/extensions/civiconfigure).  Never used this, can't speak to it.

My preferred option: The CLI CSV API export tool (there's also a GUI version available as an extension).  Here's a blog post about it: https://civicrm.org/blogs/xavier/api_batch_tools

php /path/to/modules/civicrm/bin/csv/export.php -e CustomGroup > groups.csv
php /path/to/modules/civicrm/bin/csv/export.php -e CustomField > fields.csv

php /path/to/modules/civicrm/bin/csv/import.php -e CustomGroup --file=`pwd`/groups.csv
php /path/to/modules/civicrm/bin/csv/import.php -e CustomField --file=`pwd`/fields.csv

That would export/import ALL custom fieldsets, and doesn't cover option values.  Check the blog post for filtering just the ones you want - at which point exporting the option values should become fairly self-explanatory as well.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

John.K

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 5
  • CiviCRM version: 4.x
  • CMS version: Drupal 7
  • MySQL version: 5.x
  • PHP version: 5
Re: Exporting configuration to code
October 24, 2014, 08:01:59 am
Cool, thanks for the (quick!) response Jon, good to know there are some options around.

I hadn't clicked that these were exposed to the API - it would be fairly straightforward to just use the API export/import things I expect (particularly custom field sets etc.)
« Last Edit: October 24, 2014, 08:08:35 am by .John »

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Exporting configuration to code [Solved]
October 24, 2014, 11:09:48 am
Extensions tend to use the "managed" api to, well, manage things.
http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Exporting configuration to code [Solved]

This forum was archived on 2017-11-26.