承接 manychois/pompom 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

manychois/pompom

最新稳定版本:v0.0.1

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().

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固