shish/microhtml

A minimal HTML generating library

Installs: 36 205

Dependents: 1

Suggesters: 0

Security: 0

Stars: 10

Watchers: 1

Forks: 1

Open Issues: 1

pkg:composer/shish/microhtml

v2.7.0 2026-01-17 23:19 UTC

README

Moving from Hack to vanilla PHP, I miss XHP T__T

This isn't XHP, but it does provide a minimum-bullshit method of generating HTML in a consistent and secure manner

<?php

use function MicroHTML\{HTML,SECTION,H1,P,DIV};

$page = HTML(
    SECTION(["id"=>"news"],
        H1("My title"),
        P("Here's some content")
    )
);

$page->appendChild(
    SECTION(["id"=>"comments"],
        DIV("Oh noes: <script>alert('a haxxor is attacking us');</script>")
    )
);

print($page);
<html>
    <section id='news'>
        <h1>My title</h1>
        <p>Here&#039;s some content</p>
    </section>
    <section id='comments'>
        <div>Oh noes: &lt;script&gt;alert(&#039;a haxxor is attacking us&#039;);&lt;/script&gt;</div>
    </section>
</html>

Build

src/microhtml.php is generated by gen.php

Testing

composer install
composer check

Release

git tag v1.2.3
git push --tags