Dynamic HTML builder, nothing super worth while. It does supports default HTML3, HTML4, HTML5, and XHTML tags.

1.0.2 2014-01-08 02:47 UTC


PHY\Markup gives you a nice little HTML builder. You can append/prepend elements to your main HTML element and they'll all render out on echo.

Uses a little black magic with a few __call and __get methods but they do make it nicer on the eyes.



use PHY\Markup\HTML5 as Markup;

 * Create an article tag with a class of "article".
$markup = new Markup;
$article = $markup->article;

 * Use our HTML helper to create some elements for us.
$helper = $markup->helper();
$url = $helper->url('Our Link\'s title!', [
    'key' => 'value'

 * Add some extra content to our article.
    ->append($markup->header($markup->h2('H2 Heading!'),['class' => 'header'))
    ->append($markup->section($markup->p('Inner P tag!')))

 * Recursively generate our HTML on echo.
 * Produces: <article class="article"><header class="header"><h2>H2 Heading!</h2></header><section><p>Inner P tag!</p></section><footer><a href="/rest.php?key=value">Our Link's Title!</a></footer></article>
echo $article;

 * Also, you can use the Markup::create('HTML5');
use \PHY\Markup;
$markup = Markup::create('HTML5');

 * Now for some example usage of using the Markup class itself.

$markup->add('banana', [], true);

$markup->remove('canvas', 'height');
var_dump($markup->has('canvas', 'height'));



Created this so I could dynamically create HTML blocks and link them together without having to worry about creating the actual HTML strings until it was time to push it to the server. Found it very helpful to create anchor tags as well as dynamic lists this way.


  • PHP 5.4+

Submitting bugs and feature requests

Please send bugs to me via GitHub


John Mullanaphy - - That's it for now...


PHY\Markup is licensed under the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - see the LICENSE file for details


This library was based on an old perl HTML builder I used many eons ago. I liked it then so I wanted to continue it's sexiness in PHP.


  • Finish writing tests for this.
  • Finish my other projects that utilize this class.
  • Add some more documentation and examples.
  • Maybe buff up the Factory class a bit.