gbielbarbosa/react-email-php
Composer 安装命令:
composer require gbielbarbosa/react-email-php
包简介
A PHP library to parse Tiptap JSON from @resend/react-email editor into HTML
README 文档
README
A PHP 8.1+ library designed to parse and render Tiptap JSON outputs generated by Resend React Email Editor into valid, email-safe HTML. It translates modern editor structures into cross-client compatible HTML tables.
Version Compatibility
This package processes JSON from the Resend React Email Editor. Please ensure you use compatible versions:
react-email-php |
@react-email/editor |
PHP Version |
|---|---|---|
1.x.x |
^1.0.0 |
>= 8.1 |
Installation
You can install the package via composer:
composer require gbielbarbosa/react-email-php
Usage
Converting JSON to Email-Safe HTML
To parse the JSON output from your front-end editor and render it as email-safe HTML, use the toHtml method. This method automatically handles layout components (Sections, Containers, Columns), mapping them to <table role="presentation"> tags to ensure Outlook, Apple Mail, and Gmail compatibility.
use ReactEmail\EmailParser; $json = '{"type":"doc","content":[{"type":"body","content":[{"type":"container"}]}]}'; $parser = new EmailParser(); $html = $parser->toHtml($json); echo $html;
The resulting $html will automatically include the proper HTML boilerplate (<!DOCTYPE>, <html>, <head>) if it's not present, and will dynamically inject any global styles defined in your editor's globalContent node.
Sanitizing JSON for Storage
Before saving the raw editor output to your database, you should sanitize it to prevent CSS/XSS injection payloads. The toJson method recursively traverses the JSON tree and strips invalid or malicious CSS values.
use ReactEmail\EmailParser; // Raw JSON directly from the user's request $rawJson = $_POST['editor_json']; $parser = new EmailParser(); $safeJson = $parser->toJson($rawJson); // $safeJson is now clean and ready to be stored in your database
Features
- Pure PHP implementation.
- Native rendering of complex layout components into responsive HTML tables.
- Deep integration with the Tiptap structure.
- Parses and injects global styles (from the
globalContentnode) directly into the corresponding body and container elements.
Supported Extensions
This library includes native support for the following Resend React Email Editor extensions:
- Layout blocks:
Body,Container,Section,Columns,ColumnsColumn,Div - Text elements:
Heading,Paragraph,Blockquote,CodeBlock - Media & UI:
Button,Img,Divider - Tables:
Table,TableRow,TableCell,TableHeader - Lists:
BulletList,OrderedList,ListItem - Inline Marks:
Bold,Italic,Strike,Underline,Code,Sup,Uppercase,Link
License
The MIT License (MIT). Please see License File for more information.
gbielbarbosa/react-email-php 适用场景与选型建议
gbielbarbosa/react-email-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gbielbarbosa/react-email-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gbielbarbosa/react-email-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-25