28. Local JSON Workflow | Field Forge - Custom Fields, Built for Speed
Download Log in

28. Local JSON Workflow

Developer Guide

Local JSON saves field group definitions as .json files in your theme, enabling version control and cross-environment deployment. Requires PRO license.

This is Field Forge’s own Local JSON format and uses fieldforge-json/ by default. The ACF migration tool also understands ACF’s Local JSON source files from acf-json/group_*.json, so a site can import ACF field groups even when the acf-field-group and acf-field database posts are absent.

Setup

  1. Enable Local JSON in Field Forge > Settings.
  2. Create the directory: your-theme/fieldforge-json/
  3. Field groups auto-save to this directory when edited.
bash
your-theme/
  fieldforge-json/
    group_1_product-fields.json
    group_2_hero-section.json
    .htaccess          # Auto-created: "Deny from all"
    index.php          # Auto-created: silence

Bidirectional Sync

Field Forge detects JSON changes on admin load:

  • JSON to DB: New or modified JSON files are imported into the database.
  • DB to JSON: Database changes are exported to JSON files.

Deployment Workflow

text
Development          Staging              Production
-----------          -------              ----------
1. Edit field        3. git pull          5. git pull
   groups in UI      4. Visit admin ->    6. Visit admin ->
2. git commit           auto-sync            auto-sync
   fieldforge-json/     JSON -> DB           JSON -> DB

Programmatic Sync

php
// Force export all groups to JSON
$local_json = FIELDFORGE_Local_JSON::instance();
$count = $local_json->save_all();

// Check for differences
$diff = $local_json->get_diff();
// Returns: ['new_in_json' => [...], 'new_in_db' => [...], 'modified' => [...], 'in_sync' => [1, 3]]

// Run sync (JSON wins)
$result = $local_json->sync( 'json_to_db' );

// Run sync (DB wins)
$result = $local_json->sync( 'db_to_json' );

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs