ueberdosis/tiptap-php
PHP utilities for working with Tiptap: parse and validate ProseMirror/Tiptap JSON, render or transform documents, and build extensions-friendly pipelines on the backend. Ideal for Laravel apps needing server-side handling of rich-text editor content.
Start by installing the package via Composer:
composer require ueberdosis/tiptap-php
The core entry point is Tiptap\Tiptap, which parses Tiptap JSON (ProseMirror document format). The simplest use case is rendering editor content to HTML on the server:
use Tiptap\Tiptap;
$tiptap = new Tiptap();
$html = $tiptap->render([
'type' => 'doc',
'content' => [
['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Hello world!']]]
]
]);
// Outputs: '<p>Hello world!</p>'
Check the src/ folder in the repo for the source code structure—src/Node/, src/Mark/, and src/Renderer/ are especially useful.
Tiptap::validate() to catch malformed documents:
$isValid = $tiptap->validate($jsonDocument);
if (!$isValid) { /* log/report invalid structure */ }
Tiptap\Renderer\Html and registering custom node/mark handlers.Tiptap\Extension and configure it via Tiptap::configure([...]). This ensures the server-side renderer matches the client-side editor behavior.Transform API to apply structured edits (e.g., auto-convert headings to title case, strip empty paragraphs) using Tiptap\Transformer\ChainTransformer.Tiptap as a singleton in a service provider and inject it into controllers/services handling rich-text content.schemaVersion in your editor’s output.render() internally sanitizes, validate() should run first for predictable behavior.BubbleMenu), you must register the corresponding PHP extension (or stub it with Tiptap\Node\Dummy) or rendering will fail.Tiptap::debug($json) to print a tree representation of the document—helpful when troubleshooting why content renders incorrectly.Tiptap instance per request. Reuse it (e.g., as a shared service) since initialization involves extension loading and schema setup.Tiptap in unit tests using predefined Tiptap JSON fixtures. A good practice is to store sample valid.json and invalid.json files under tests/fixtures/.How can I help you explore Laravel packages today?