manychois/pompom
Composer 安装命令:
composer require manychois/pompom
包简介
Modern PHP DOM-based HTML templating helpers for building reusable templates with PHP 8.5+.
README 文档
README
Pompom is a PHP library for building HTML with a component-based, DOM-first workflow: you compose templates from PHP classes that yield Dom\* nodes, not from string assembly or a separate template language.
Get started
You will install the package and render one named component to a Dom\HTMLDocument, then print HTML. You need PHP 8.5+ with ext-dom.
1. Install
composer require manychois/pompom
2. Render a root component
Register a component resolver (here Psr4ComponentResolver) so a string name maps to a component class. Build an engine, call render, then serialize:
use Manychois\Pompom\Engine; use Manychois\Pompom\Internal\Psr4ComponentResolver; $resolver = new Psr4ComponentResolver([ 'MyApp\\Components' => __DIR__ . '/src/Components', ]); $engine = new Engine($resolver); $document = $engine->render('hello-page', ['name' => 'World']); echo $document->saveHtml();
You should see HTML produced by your hello-page component (that class must exist at the path implied by your PSR-4 mapping).
How to …
Run tests and quality checks in this repository
If documentation/internal/ is missing, initialize the submodule:
git submodule update --init documentation/internal
Then:
composer install composer test # PHPUnit (with coverage) composer phpstan # static analysis composer phpcs # style and docblocks
About Pompom
Pompom is built around PHP 8.5+ and the modern Dom\* API (Dom\HTMLDocument, Dom\Element, …), not the legacy DOMDocument stack. The goal is reusable, testable pieces that return real DOM trees.
Resolution and rendering. You map arbitrary component names (e.g. hello-page) to classes via a component resolver. The engine creates an empty Dom\HTMLDocument, instantiates the root component, and iterates render($props). Constructor injection gives only shared dependencies such as the document and engine; render-time data is always $props, not the DI container.
What components output. Components yield mixed values (text, nodes, nested component references). A content resolver turns each chunk into Dom\Node instances and the engine appends them. The root component is responsible for the full document shape (<html>, <head>, <body> if you need a full page); the engine does not insert those for you.
Composition. Typical pieces include AbstractComponent, NodeUtility for element helpers, component() / ComponentBuilder for child components, and children / named regions for slot-like content.
Why DOM-first. Output stays structured and easy to assert in tests (saveHtml(), walking nodes) and avoids ad-hoc concatenation; optional Prettier can indent HTML for readability before serialization.
Reference
| Package | manychois/pompom |
| PHP | >= 8.5 |
| Extensions | ext-dom |
| Symbol | Role |
|---|---|
Engine |
Builds an empty Dom\HTMLDocument, resolves the root component, consumes render() output. |
ComponentResolverInterface |
Maps a component name to a component class (e.g. Psr4ComponentResolver). |
AbstractComponent |
Base for components; render() / getContent() pipeline, component(), children and regions. |
ContentResolverInterface |
Turns mixed yielded content into Dom\Node for a given document. |
Prettier |
Optional in-place formatting before saveHtml(). |
Serialization uses Dom\HTMLDocument methods such as saveHtml() and saveHtmlFile().
manychois/pompom 适用场景与选型建议
manychois/pompom 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 manychois/pompom 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 manychois/pompom 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-08