shish / microhtml
A minimal HTML generating library
Installs: 18 751
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.12
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.0
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's some content</p> </section> <section id='comments'> <div>Oh noes: <script>alert('a haxxor is attacking us');</script></div> </section> </html>
Testing
composer install
./vendor/bin/php-cs-fixer fix
./vendor/bin/phpunit tests
./vendor/bin/phpstan analyse src tests --level 5
Release
git tag v1.2.3
git push --tags