PHPackages                             stoutlogic/acf-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stoutlogic/acf-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stoutlogic/acf-builder
======================

An Advanced Custom Field Configuration Builder

v1.12.0(4y ago)8371.9M↓51.5%60[27 issues](https://github.com/StoutLogic/acf-builder/issues)[10 PRs](https://github.com/StoutLogic/acf-builder/pulls)20GPL-2.0+PHPPHP &gt;=5.4.0CI failing

Since May 16Pushed 2y ago31 watchersCompare

[ Source](https://github.com/StoutLogic/acf-builder)[ Packagist](https://packagist.org/packages/stoutlogic/acf-builder)[ RSS](/packages/stoutlogic-acf-builder/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (24)Used By (20)

ACF Builder
===========

[](#acf-builder)

Create configuration arrays for [Advanced Custom Fields Pro](https://www.advancedcustomfields.com/pro/) using the builder pattern and a fluent API.

Quickly create, register, and reuse ACF configurations, and keep them in your source code repository. To read more about registering ACF fields via php consult

[![Latest Stable Version](https://camo.githubusercontent.com/404e4450f5b6b85cc1455001ce6c823ef64f919fcffd4a6aaea1a232db34215b/68747470733a2f2f706f7365722e707567782e6f72672f73746f75746c6f6769632f6163662d6275696c6465722f762f737461626c65)](https://packagist.org/packages/stoutlogic/acf-builder)[![Build Status](https://github.com/stoutlogic/acf-builder/workflows/TESTS/badge.svg)](https://github.com/StoutLogic/acf-builder/actions?query=workflow%3ATESTS)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7c15e183af239b0ea0a292a6b5b8f77eb7329746e80c3e17848f1fd895cc44df/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53746f75744c6f6769632f6163662d6275696c6465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/StoutLogic/acf-builder/?branch=master)[![Join the chat at https://gitter.im/StoutLogic/acf-builder](https://camo.githubusercontent.com/2f42405e8f9aa2e92b3863b63d63104fc9031399b349430403319d373eae1c22/68747470733a2f2f6261646765732e6769747465722e696d2f53746f75744c6f6769632f6163662d6275696c6465722e737667)](https://gitter.im/StoutLogic/acf-builder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

### Simple Example

[](#simple-example)

```
$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner');
$banner
    ->addText('title')
    ->addWysiwyg('content')
    ->addImage('background_image')
    ->setLocation('post_type', '==', 'page')
        ->or('post_type', '==', 'post');

add_action('acf/init', function() use ($banner) {
   acf_add_local_field_group($banner->build());
});
```

`$banner->build();` will return:

```
[
    'key' => 'group_banner',
    'title' => 'Banner',
    'fields' => [
        [
            'key' => 'field_title',
            'name' => 'title',
            'label' => 'Title',
            'type' => 'text'
        ],
        [
            'key' => 'field_content',
            'name' => 'content',
            'label' => 'Content',
            'type' => 'wysiwyg'
        ],
        [
            'key' => 'field_background_image',
            'name' => 'background_image',
            'label' => 'Background Image',
            'type' => 'image'
        ],
    ],
    'location' => [
        [
            [
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'page'
            ]
        ],
        [
            [
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'post'
            ]
        ]
    ]
]
```

As you can see it saves you a lot of typing and is less error-prone. But brevity and correctness isn't the only benefit, you can reuse field configurations in multiple places. For example, a group of fields used for backgrounds:

### Reuse Example

[](#reuse-example)

```
use StoutLogic\AcfBuilder\FieldsBuilder;

$background = new FieldsBuilder('background');
$background
    ->addTab('Background')
    ->addImage('background_image')
    ->addTrueFalse('fixed')
        ->instructions("Check to add a parallax effect where the background image doesn't move when scrolling")
    ->addColorPicker('background_color');

$banner = new FieldsBuilder('banner');
$banner
    ->addTab('Content')
    ->addText('title')
    ->addWysiwyg('content')
    ->addFields($background)
    ->setLocation('post_type', '==', 'page');

$section = new FieldsBuilder('section');
$section
    ->addTab('Content')
    ->addText('section_title')
    ->addRepeater('columns', ['min' => 1, 'layout' => 'block'])
        ->addTab('Content')
        ->addText('title')
        ->addWysiwyg('content')
        ->addFields($background)
        ->endRepeater()
    ->addFields($background)
    ->setLocation('post_type', '==', 'page');
```

Here a `background` field group is created, and then used in two other field groups, including twice in the `section` field group. This can really DRY up your code and keep your admin UI consistent. If you wanted to add a light/dark field for the text color field based on the background used, it would just need to be added in one spot and used everywhere.

Install
-------

[](#install)

Use composer to install:

```
composer require stoutlogic/acf-builder

```

If your project isn't using composer, you can require the `autoload.php` file.

Tests
-----

[](#tests)

To run the tests you can manually run

```
vendor/bin/phpunit

```

or you can use the built in gulp task to run it on file change

```
npm install
gulp

```

Requirements
------------

[](#requirements)

PHP 5.4 through 7.2 supported but automated tests cannot be run anymore so it might stop working at some point.

> = 7.4, 8 Tested

Documentation
-------------

[](#documentation)

See the [wiki](https://github.com/StoutLogic/acf-builder/wiki) for more thorough documentation. The documentation has its [own repository](https://github.com/StoutLogic/acf-builder-wiki) and accepts pull requests for contributions. Any merges to master will get synced with the wiki here under the main project.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity63

Solid adoption and visibility

Community43

Growing community involvement

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 87.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Recently: every ~162 days

Total

21

Last Release

1726d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.3PHP &gt;=5.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13740017?v=4)[Stout Logic, LLC](/maintainers/stoutlogic)[@StoutLogic](https://github.com/StoutLogic)

---

Top Contributors

[![stevep](https://avatars.githubusercontent.com/u/9717?v=4)](https://github.com/stevep "stevep (178 commits)")[![michaelw85](https://avatars.githubusercontent.com/u/3629094?v=4)](https://github.com/michaelw85 "michaelw85 (4 commits)")[![aprokopenko](https://avatars.githubusercontent.com/u/1842666?v=4)](https://github.com/aprokopenko "aprokopenko (3 commits)")[![Log1x](https://avatars.githubusercontent.com/u/5745907?v=4)](https://github.com/Log1x "Log1x (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (3 commits)")[![Androlax2](https://avatars.githubusercontent.com/u/39646949?v=4)](https://github.com/Androlax2 "Androlax2 (2 commits)")[![guix77](https://avatars.githubusercontent.com/u/4377644?v=4)](https://github.com/guix77 "guix77 (2 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (2 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![tombroucke](https://avatars.githubusercontent.com/u/24292260?v=4)](https://github.com/tombroucke "tombroucke (1 commits)")[![davddo](https://avatars.githubusercontent.com/u/5182811?v=4)](https://github.com/davddo "davddo (1 commits)")[![DalkMania](https://avatars.githubusercontent.com/u/2073239?v=4)](https://github.com/DalkMania "DalkMania (1 commits)")[![theMosaad](https://avatars.githubusercontent.com/u/48773133?v=4)](https://github.com/theMosaad "theMosaad (1 commits)")[![titouanmathis](https://avatars.githubusercontent.com/u/250145?v=4)](https://github.com/titouanmathis "titouanmathis (1 commits)")[![ken-gladeye](https://avatars.githubusercontent.com/u/65751307?v=4)](https://github.com/ken-gladeye "ken-gladeye (1 commits)")

---

Tags

acfcomposerwordpress

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/stoutlogic-acf-builder/health.svg)

```
[![Health](https://phpackages.com/badges/stoutlogic-acf-builder/health.svg)](https://phpackages.com/packages/stoutlogic-acf-builder)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[illuminate/support

The Illuminate Support package.

582110.9M39.4k](/packages/illuminate-support)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k116.2M670](/packages/symfony-maker-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M306](/packages/api-platform-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M180](/packages/api-platform-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
