Speeding Up Laravel Tests with tmpfs (MySQL in RAM)
If your Laravel test suite is painfully slow and does a lot of database work (multi-tenancy, migrations, seeding), the bottleneck is almost…
When working with Statamic's Bard fieldtype programmatically, you'll often need to convert its structured data to HTML. The documentation doesn't make this obvious, but here's how to do it properly.
Bard stores content as a structured array based on ProseMirror's document format. When you access it via $entry->get('content'), you get the raw array structure. Using $entry->augmentedValue('content') gives you a Value object, but calling ->value() or casting to string often returns plain text without HTML tags or links.
Use Statamic's CoreModifiers class with the bardHtml method:
use Statamic\Modifiers\CoreModifiers;
$bardValue = $entry->augmentedValue('article_builder');
$modifiers = new CoreModifiers();
$html = $modifiers->bardHtml($bardValue);
This properly renders:
statamic://entry::abc-123)Here's a complete example for rendering Bard content from an entry:
use Statamic\Facades\Entry;
use Statamic\Modifiers\CoreModifiers;
$entry = Entry::find($entryId);
if ($entry->has('content')) {
$augmented = $entry->augmentedValue('content');
if ($augmented) {
$modifiers = new CoreModifiers();
$html = $modifiers->bardHtml($augmented);
// Now $html contains properly formatted HTML
echo $html;
}
}
If you need more control over the rendering process, you can use the Bard Augmentor directly:
use Statamic\Fieldtypes\Bard\Augmentor;
$fieldtype = $entry->blueprint()->field('content')->fieldtype();
$augmentor = (new Augmentor($fieldtype))->withStatamicImageUrls();
$content = $entry->get('content');
$html = $augmentor->augment($content);
But for most use cases, CoreModifiers::bardHtml() is simpler and more reliable.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com