PHPackages                             alcamo/html-creation - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. alcamo/html-creation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alcamo/html-creation
====================

Simple classes to create HTML code without need for a factory

0.11.4(3mo ago)0216↓50%1Apache-2.0PHPPHP 7.3 - 8.0

Since Jun 30Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/rv1971/alcamo-html-creation)[ Packagist](https://packagist.org/packages/alcamo/html-creation)[ RSS](/packages/alcamo-html-creation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (27)Used By (1)

Usage example
=============

[](#usage-example)

```
use alcamo\html_creation\element\{
    Body,
    Head,
    Html,
    Li,
    P,
    Style,
    Title,
    Ul
};

use alcamo\xml_creation\{DoctypeDecl, Nodes};

include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

$baz = new Li('baz');

$baz['class']->add('bold');

$html = new Nodes (
    new DoctypeDecl('html'),
    new Html(
        [
            new Head(
                [
                    new Title('Hello'),
                    new Style('.bold { font-weight: bold }')
                ]
            ),
            new Body(
                [
                    new P('Hello, world!', [ 'id' => 'hello' ] ),
                    Ul::newFromItems(
                        [
                            'foo',
                            'bar',
                            $baz
                        ]
                    )
                ]
            )
        ]
    )
);

Nodes::setFormatOutput(true);

echo $html . PHP_EOL;

```

This example is contained in this package as a file in the `bin`directory. It will output

```

Hello
.bold { font-weight: bold }

Hello, world!

foo
bar
baz

```

Overview
========

[](#overview)

The package offers one class for each HTML element.

For most of them, the constructor takes two parameters, the element content and optionally the attributes. (Some elements have different constructors, in particular elements like `` which do not have a content).

The content can be:

- An iterable, whose items will be output one after the other.
- An `alcamo\xml_creation\Nodes` object, which will be handled like an iterable.
- A stringable, which will be output with the special characters &amp;,&lt;,&gt; escaped.
- An `alcamo\xml_creation\Raw` object which will be output unchanged.

Each element automatically has an attribute `class` of type `alcamo\xml_creation\TokenList` which is empty at the beginning. This makes it easy to add classes to an element without caring whether it already has a `class` attribute (and whether is already has the class to add), as in the above example. Attributes having an empty `TokenList` are suppressed in the output.

Many classes have additional factory methods to simplify HTML creation, such as `Ul::newFromItems()` in the above example. These methods are one of the primary reasons why this package may be useful.

See the doxygen documentation for details.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance81

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~67 days

Recently: every ~2 days

Total

26

Last Release

102d ago

PHP version history (2 changes)0.1PHP 7.3 - 7.4

0.1.2PHP 7.3 - 8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/db9722b60c5a69929f1d1c7df3d0d8682d74ed19146a2cdd2dfffa7ddc4abc78?d=identicon)[rv1971](/maintainers/rv1971)

---

Top Contributors

[![rv1971](https://avatars.githubusercontent.com/u/39520256?v=4)](https://github.com/rv1971 "rv1971 (39 commits)")

---

Tags

factoryhtml

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/alcamo-html-creation/health.svg)

```
[![Health](https://phpackages.com/badges/alcamo-html-creation/health.svg)](https://phpackages.com/packages/alcamo-html-creation)
```

###  Alternatives

[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[ckeditor/ckeditor

JavaScript WYSIWYG web text editor.

5234.2M76](/packages/ckeditor-ckeditor)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21320.9M15](/packages/caxy-php-htmldiff)[yajra/laravel-datatables-html

Laravel DataTables HTML builder plugin

2899.6M48](/packages/yajra-laravel-datatables-html)[wa72/htmlpagedom

jQuery-inspired DOM manipulation extension for Symfony's Crawler

3383.9M34](/packages/wa72-htmlpagedom)[tinymce/tinymce

Web based JavaScript HTML WYSIWYG editor control.

1697.5M106](/packages/tinymce-tinymce)

PHPackages © 2026

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