PHPackages                             theaomx/htmlnode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. theaomx/htmlnode

ActiveLibrary

theaomx/htmlnode
================

Create custom HTML-Markup by constructing AST-Node-Trees with an easy-to-use HtmlBuilder that implements the builder pattern.

1.0.7(10mo ago)033MITPHPPHP &gt;=8.0.0

Since Mar 31Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/TheAomx/PHP-HTML-Node)[ Packagist](https://packagist.org/packages/theaomx/htmlnode)[ Docs](https://github.com/TheAomx/PHP-HTML-Node)[ RSS](/packages/theaomx-htmlnode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (9)Used By (0)

PHP-HTML-Node
=============

[](#php-html-node)

This is a project that allows you to represent arbritary HTML-AST-Node-Trees in your PHP-Code. This is useful for several reasons. If you use these classes in your projects you are working on trees of nodes instead of strings. Therefore you can pass these instances from one method to another and manipulate the trees directly. Only if the root of the tree or another part of the tree is printed with echo or print then the tree gets converted into the right HTML-Tags. Please take a look at the index.php that creates a sample website and you can see the relevant api-calls there.

simple example which creates an HTML5 barebone website
------------------------------------------------------

[](#simple-example-which-creates-an-html5-barebone-website)

```
use \TheAomx\Nodes\HtmlNode as HtmlNode;
use \TheAomx\Nodes\Indentation as Indentation;

$html = HtmlNode::get_builder("html")->attr("lang", "de")->build();

$head = HtmlNode::get_builder("head")->build();
$charset = HtmlNode::get_builder("meta")->attr("charset", "utf-8")->build();
$viewport = HtmlNode::get_builder("meta")->attr("name", "viewport")->
                attr("content", "width=device-width, initial-scale=1.0")->build();
$title = HtmlNode::get_builder("title")->text("Hello World Site")->build();
$head->addChildNode($charset)->addChildNode($viewport)->addChildNode($title);

$body = HtmlNode::get_builder("body")->build();
$html->append($head)->append($body);

$h1 = HtmlNode::get_builder("h1")->text("Welcome stranger!")->build();
$p = HtmlNode::get_builder("p")->attr("style", "color: red;")->
                attribute("align", "left")->build();
$b = HtmlNode::get_builder("b")->s_text("Hello World with umlaute äöü&%")->build();
$p->append($b);

$body->append($h1)->append($p);

// only at this step the root ast-node $html gets converted to a string!
echo $html;
```

The resulting html of the above example would be like this. If you want you can disable the pretty printing of the html output, such that no blank lines or spaces have to be transferred.

```

      Hello World Site

      Welcome stranger!

        Hello World with umlaute &auml;&ouml;&uuml;&amp;%

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance54

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~431 days

Recently: every ~661 days

Total

8

Last Release

308d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

1.0.6PHP &gt;=8.0.0

### Community

---

Top Contributors

[![TheAomx](https://avatars.githubusercontent.com/u/6179854?v=4)](https://github.com/TheAomx "TheAomx (22 commits)")

### Embed Badge

![Health badge](/badges/theaomx-htmlnode/health.svg)

```
[![Health](https://phpackages.com/badges/theaomx-htmlnode/health.svg)](https://phpackages.com/packages/theaomx-htmlnode)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
