Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rich Text Laravel Package

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+.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Content Strategy & CMS-Driven Features:

    • Enable rich-text editing in Contentful for marketing teams, reducing reliance on frontend devs for HTML/CSS tweaks.
    • Support multi-locale content (e.g., global sites) via parseLocalized() to avoid localization bugs in embedded assets/entries.
    • Dynamic content rendering (e.g., blogs, product descriptions) without hardcoding templates—customize via NodeRenderer interfaces.
  • Roadmap Priorities:

    • Build vs. Buy: Avoid reinventing a rich-text parser/renderer for Laravel/PHP projects. This package is maintained by Contentful (enterprise-grade) and aligns with their ecosystem.
    • Headless CMS Integration: Critical for projects using Contentful as a backend (e.g., React/Vue frontends consuming PHP APIs).
    • Editorial Workflows: Empower content creators to use tables, strikethrough, superscripts, etc., without dev intervention (see changelog for supported features).
  • Use Cases:

    • Marketing Sites: Dynamic landing pages with localized content.
    • E-Commerce: Product descriptions with embedded images/assets.
    • Documentation: Structured content (e.g., API docs) with syntax highlighting via custom NodeRenderers.
    • Legacy Migration: Gradually adopt Contentful while keeping PHP backends (e.g., Laravel).

When to Consider This Package

  • Adopt When:

    • Your stack uses Laravel/PHP + Contentful for content management.
    • You need structured rich-text parsing/rendering (e.g., nested nodes, embedded assets).
    • Your team requires customizable output (e.g., Twig/Plates templates, CSS classes for headings).
    • You’re building multi-locale or editorial-heavy applications (e.g., CMS-driven sites).
    • You want to avoid reinventing parsing logic for Contentful’s rich-text format.
  • Look Elsewhere If:

    • You’re not using Contentful: This package is Contentful-specific (e.g., won’t work with WordPress or custom JSON).
    • Your rich-text needs are simple (e.g., basic Markdown → HTML). Use a lighter package like spatie/laravel-markdown.
    • You need real-time collaboration (e.g., Google Docs-like editing). Consider a dedicated WYSIWYG editor (e.g., TinyMCE, CKEditor).
    • Your team lacks PHP/Laravel expertise to implement custom NodeRenderers or handle edge cases (e.g., unsupported nodes).
    • You require serverless/edge rendering (e.g., Cloudflare Workers). This package is PHP-centric.

How to Pitch It (Stakeholders)

For Executives:

"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:

  • Faster content updates: Non-technical teams manage rich-text content.
  • Consistent branding: Customize rendering (e.g., brand-specific CSS classes) via simple PHP classes.
  • Scalable: Handles complex nested content (tables, lists, embedded assets).
  • Future-proof: Aligns with Contentful’s roadmap (e.g., new rich-text features like strikethrough).

For Engineering:

*"This is a batteries-included parser/renderer for Contentful’s rich-text format. It handles:

  • Parsing: Converts Contentful’s JSON-rich-text into a traversable PHP object graph (e.g., Heading1, EmbeddedAssetBlock).
  • Rendering: Defaults for all node types, but we can override any output via NodeRendererInterface (e.g., wrap headings in custom classes, integrate with Twig/Plates).
  • Localization: Avoids bugs with embedded assets/entries in multi-locale setups via parseLocalized().
  • Extensibility: Supports custom templates (e.g., Twig/Plates) and edge cases (e.g., CatchAll renderer for unsupported nodes).

Implementation Notes:

  • Setup: composer require contentful/rich-text + link resolver for embedded assets.
  • Customization: Extend NodeRendererInterface for bespoke logic (e.g., syntax highlighting for code blocks).
  • Performance: Lightweight (~50KB) with no external dependencies beyond PHP 7.2+.
  • Alternatives: If we need simpler Markdown support, we could pair this with a lighter package, but this is the official Contentful tool for rich-text.

Example Workflow:

  1. Contentful stores rich-text in an entry (e.g., blogPost.body).
  2. PHP backend parses it: $node = $parser->parseLocalized($data, 'en-US').
  3. Render with custom logic: $renderer->pushNodeRenderer(new CustomHeading1()).
  4. Output HTML for frontend or API response.

Risks:

  • Learning Curve: Requires understanding NodeInterface hierarchy and NodeRenderer patterns.
  • Unsupported Nodes: Default renderer throws exceptions; use CatchAll for graceful fallback.
  • Contentful Lock-in: Tight coupling to Contentful’s rich-text format (but this is intentional for our use case)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky