Frontmatter

PHP adapter

The PHP adapter generates plain PHP include-based templates — no templating engine required. Works with WordPress, custom CMS, legacy PHP, and any PHP backend.

Usage

frontmatter solo:build --adapter php
frontmatter solo:build --adapter php --out ./render-pack

Mapping rules

Required props

<?php // Astro: headline: string ?>
<?= htmlspecialchars($fm['props']['headline']) ?>

Optional props

<?php // Astro: sub?: string ?>
<?php if (!empty($fm['props']['sub'])): ?>
  <p><?= htmlspecialchars($fm['props']['sub']) ?></p>
<?php endif; ?>

Array iteration

<?php foreach ($fm['data']['items'] as $item): ?>
  <?php
    $fm['props'] = $item;
    include __DIR__ . '/../partials/card.php';
  ?>
<?php endforeach; ?>

Layout include

<?php // pages/index.php
// Populate fm from your data source
$fm = [
  'page' => ['title' => 'Home'],
  'data' => [
    'hero' => [
      'headline' => 'Welcome',
      'sub'      => 'We build things.',
    ],
  ],
];

include __DIR__ . '/../layouts/base.php';

Output structure

output/
├─ pages/
│  └─ index.php
├─ layouts/
│  └─ base.php
├─ partials/
│  ├─ hero.php
│  └─ section.php
├─ manifest.json
├─ INTEGRATION.md
└─ frontmatter.build.json

WordPress integration

Solo generates the partials and layouts. It does not generate WordPress-specific files (functions.php, hooks, queries). Drop the output into your theme folder and wire $fm['props'] from your data source:

<?php // Your WordPress page template — you write this
// Solo generates: partials/hero.php, layouts/base.php, INTEGRATION.md

$fm = [
  'props' => [
    'headline' => get_field('hero_headline'), // ACF, post meta, etc.
    'sub'      => get_field('hero_sub'),
  ]
];

include get_template_directory() . '/partials/hero.php';
Escaping. Solo generates htmlspecialchars() by default — standard PHP. If you're integrating into WordPress, replace with esc_html() and esc_url(). The templates are plain PHP files, fully editable.

Custom PHP CMS

The PHP output works with any backend that can execute PHP includes. Populate $fm from your data source and include the generated partials. No dependency on Twig, Blade, or any other templating engine.

On this page