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. [HTTP &amp; Networking](/categories/http)
4. /
5. theaomx/htmlnode

ActiveLibrary[HTTP &amp; Networking](/categories/http)

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(12mo ago)034MITPHPPHP &gt;=8.0.0CI failing

Since Mar 31Pushed 2mo 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 2d ago

READMEChangelog (8)Dependencies (1)Versions (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

43

—

FairBetter than 90% of packages

Maintenance70

Regular maintenance activity

Popularity7

Limited adoption so far

Community7

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

361d ago

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

1.0.6PHP &gt;=8.0.0

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

httptreeastmarkupnode

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B3.9k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.0k1.1B6.7k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k747.1M2.6k](/packages/psr-http-factory)[psr/http-client

Common interface for HTTP clients

1.7k731.6M2.9k](/packages/psr-http-client)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k338.8M4.7k](/packages/symfony-http-client)[psr/link

Common interfaces for HTTP links

2.5k152.8M84](/packages/psr-link)

PHPackages © 2026

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