ACF PHP vs. JSON Overview

This article list the pros and cons of ACF JSON and ACF PHP. This article already assumes you know what ACF and WordPress is, and have working knowledge of the WordPress directory.

I was recently given the pleasure of researching the pros vs. cons of ACF (Advanced Custom Fields) PHP vs. JSON export to identify future maintenance of existing WordPress stack utilizing ACF.  Prior to this project I have always been taught to use the ACF JSON export when working with multiple devs. Even in my research ACF JSON seemed to be the solution to managing your ACF with multiple devs. My assumption based on my research was to use ACF JSON for collaboration among other devs. But in previous projects maintaining ACF utilizing JSON I found syncing issues and fields would go missing between environments.

In addition utilizing the ACF JSON feature with Git we would run into issues with version control. I found to be the real benefit of the ACF JSON is you get to use the nice ACF JSON GUI in the WP-Admin which can make for easier for development but if you are willing to take make the effort, utilizing the ACF PHP to maintain isn’t so bad. Plus utilizing the ACF PHP export it allows for easier version control with Git, and control of the ACF instead of exposing them in the WP-Admin for Administrators (Note: you most likely can control ACF viewing in the WP-Admin utilizing functions.php file). For now going moving forward with future projects I will try to maintain ACF utilizing PHP and see how it goes, can always change in the future.

ACF PHP Pros and Cons

Pros​ of ACF PHP

  • It does help with binding field logic to a theme.
  • This feature is a one-way export.
  • Allows for greater control via customfields.php
  • May avoid Git versioning conflict
  • May avoid ACF JSON syncing issues

Cons​ of ACF PHP

  • ACF PHP export does not help with version control and local development? – Not neccarsily, see pros above.
  • To perform CRUD (create, updated, delete) on existing ACF there isn’t a way to do this. ​- Has to be done via PHP, see here.
  • Now, there is a plugin that enables you to do this, but ACF doesn’t do it by default
  • Because of the one-way export, once it has been exported and transferred to another environment, you cannot easily change or extend the ACF settings.​ – Again you can register fields via the PHP export
  • Also, this method doesn’t work well with merging two different setups that has been developed separately.
  • A field group in PHP file will not show up in the ACF admin unless you import a JSON file.

ACF JSON Pros and Cons

Pros of ACF JSON

  • If you only require a solution for distribution across multiple environments, please familiarize yourself with the local json feature as this solves the issue with minimal effort.
  • Local JSON is a new feature added in version 5 which saves field group and field settings as .json files within your theme. The idea is similar to caching, and both dramatically speeds up ACF and allows for version control over your field settings!
  • The real power in ‘local JSON’ is the ability to sync changes. This allows multiple devs to work on a project, use git to push / pull files, and keep all databases synchronized with the latest field group settings!
  • JSON field groups will be available for sync when either the JSON field group does not exist in the DB, or when the JSON field group contains a higher ‘modified’ value (within the JSON array) than the DB post’s modified date.
  • When fields groups are detected for synchronization, you will see a new tab above the field group list where you can select the groups to be imported.
  • ACF’s Local JSON feature can dramatically boost performance when it comes to your custom fields. It works similar to caching in that it saves both field group and field settings as a .json file on your web server.

Cons of ACF JSON

  • ACF JSON Conflicts with Syncing and Git versioning.
  • Keep ACF field groups out of the production site’s database.
  • Only make changes to field group settings locally.
  • Hide the ACF Field Groups admin page on the production copy of the site.
  • Good article on possible conflicts with JSON: and why we should follow the above instructions.

This article was put together by the following resources:

Conclusion of ACF JSON vs. PHP

It’s really depends on the project and your personal preference. Do you want to make the development harder on yourself/team, to avoid versioning/syncing issues with ACF? Or do you want to have easier CRUD via WP-Admin GUI? The choice is up to you, be flexible and figure what works out for you and your team.


Leave a Reply

Your email address will not be published. Required fields are marked *