When you build custom Gutenberg blocks inside a Sage theme, the Roots-community answer is Log1x’s acf-composer — you declare a block as a PHP class and it handles the rest. The catch: it renders through ACF Blocks, an ACF Pro feature. We wanted that experience without the paid dependency, so we built our own.
Two unappealing options
Out of the box you either call register_block_type() for every block and hand-write the editor JavaScript to match, or you buy ACF Pro. The first is repetitive and drifts out of sync; the second is a licence for something we could do ourselves.
One class per block
Every block is now a small PHP class. You declare its name, its Blade view, and its fields — and a base class derives the WordPress attributes and registers the block with a Blade render callback.
class Hero extends Block
{
public string $name = 'rootstest/hero';
public string $view = 'blocks.hero';
public array $fields = [
'title' => ['type' => 'text', 'label' => 'Title'],
'lead' => ['type' => 'textarea', 'label' => 'Lead'],
];
}
A make:block command
Because it is all Acorn, we added a console command. wp acorn make:block Feature scaffolds the class and a Blade view, and the block is auto-discovered and registered — no wiring, no build step.
The editor generates itself
A single, generic editor script reads each block’s field definitions (handed over from PHP) and builds the sidebar controls plus a neutral placeholder. Adding a new block never touches JavaScript, and the polished dark styling stays on the front end where it belongs.
The whole point
Define a block in one PHP class, render it with Blade, scaffold it with a command — the acf-composer experience, minus ACF Pro.