contentful/rich-text
PHP library for parsing and rendering Contentful Rich Text fields. Parses localized rich text JSON into node objects, resolves linked assets/entries via a link resolver, and renders nodes to output with a simple Renderer API. Requires PHP 7.2+ / 8.0+.
Content Strategy & CMS-Driven Features:
parseLocalized() to avoid localization bugs in embedded assets/entries.NodeRenderer interfaces.Roadmap Priorities:
Use Cases:
NodeRenderers.Adopt When:
Look Elsewhere If:
spatie/laravel-markdown.NodeRenderers or handle edge cases (e.g., unsupported nodes)."This package lets us leverage Contentful’s rich-text fields without sacrificing control over the output. It’s a turnkey solution for dynamic content—marketing teams can edit copy directly in Contentful, while we customize how it renders (e.g., adding classes for styling, integrating with Twig templates). It’s maintained by Contentful, so we avoid tech debt, and it supports multi-language sites out of the box. For example, we could use it to power our global blog or product descriptions with embedded images—no frontend devs needed for HTML tweaks."
Key Benefits:
*"This is a batteries-included parser/renderer for Contentful’s rich-text format. It handles:
Heading1, EmbeddedAssetBlock).NodeRendererInterface (e.g., wrap headings in custom classes, integrate with Twig/Plates).parseLocalized().CatchAll renderer for unsupported nodes).Implementation Notes:
composer require contentful/rich-text + link resolver for embedded assets.NodeRendererInterface for bespoke logic (e.g., syntax highlighting for code blocks).Example Workflow:
blogPost.body).$node = $parser->parseLocalized($data, 'en-US').$renderer->pushNodeRenderer(new CustomHeading1()).Risks:
NodeInterface hierarchy and NodeRenderer patterns.CatchAll for graceful fallback.How can I help you explore Laravel packages today?