PHP-based HTML Markup generator

Installs: 3

Dependents: 0

Stars: 3

Watchers: 2

Open Issues: 1

Type: markup

2.0.10 2013-04-22 10:54 UTC


The main benefits are:

  • no switching between php and html or echoing of html strings needed when you are inside your php stuff.
  • Minimalistic usage attempt and helper functions. You should be able to generate more html markup with less php instructions while keeping full flexibility.
  • Auto-indention. Unless you turn it of to save whitespace you will receive beautifully indented and super-readable markup for your web-projects.

The main downfalls are:

  • Page generation takes longer, because every html-tag will run through a lot of php functions while being generated.
    (I use it along with wordpress and can not make a humanly noticeable difference in page loading speed when changing from a default wp-theme to one that uses the generator.)
  • It may be difficult to learn how to use this, compared to writing pure html.

This project is inspired by the CakePHP HtmlHelper.




  1. Download the latest "alldeps" branch
  2. Extract the archive and upload the plugin into the /wp-content/plugins/ directory of your wordpress project.
  3. Activate the plugin through the 'Plugins' menu in WordPress


Use composer and require "xiphe/html": "2.0.*"

or download the latest "alldeps" branch, extract it and put it anywhere in your php project. Then include [path to]/bootstrap.php or [path to]/vendor/autoload.php.

Basic Usage

Follow the Installation steps to initiate the global $HTML variable.

/* Get access to an instance of Xiphe\HTML */
global $HTML

/* Opens a std HTML5 header - leaves you inside the <head> */
    /* print a <title> */
    ->title('HTML Example')
/* close the <head> tag */
/* open a <body> tag (s_[tag] will just open a [tag] - no </tag> will be echoed) */
    /* open a <div> tag with the class attribute "wrap" */
        /* open an <article> tag with an id */
            /* print a <h1> with multiple attributes */
            ->h1('Hello Stranger', array('style' => 'color: red;', 'rel' => 'title'))
            /* <3 */
            ->p('Thank you for checking out Xiphe\HTML - that\'s very kind of you')
            /* Another way to pass multiple attributes to a tag */
/* close all Tags that have been opened previously */


<html class="no-js">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
        <title>HTML Example</title>
        <div class="wrap">
            <article id="article1">
                <h1 rel="title" style="color: red;">Hello Stranger</h1>
                <p>Thank you for checking out Xiphe\HTML - that's very kind of you</p>
                <img alt="example" src="http://upload.wikimedia.org/wikipedia/commons/c/ce/Example_image.png" />
            </article><!-- #article1 -->
        </div><!-- .wrap -->
</html><!-- .no-js -->

Want to dig deeper? poke me to write a better documentation. Or check out the Test/Examples Hybrid on html.xiphe.net.

3rd Party

  • Js/Css Minifiying from Fat-Free Framework
    Distributed under the GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
    Copyright (c) 2009-2012 F3::Factory/Bong Cosca
  • PHP Diff by Chris Boulton (Used for the Demos/Tests. Will not be loaded in productive usage).
    BSD License
    Copyright (c) 2009 Chris Boulton chris.boulton@interspire.com
    All rights reserved.
  • Markdown
    PHP Markdown & Extra
    Copyright (c) 2011, Dragonfly Development Inc
    All rights reserved.

    Based on PHP Markdown & Extra
    Copyright (c) 2004-2009 Michel Fortin
    All rights reserved.

    Based on Markdown
    Copyright (c) 2003-2006 John Gruber
    All rights reserved.

  • phpDocumentor was used to generate the documentation under /doc



  • mergeClasses method added to core\Generator


  • minor bugfixes and compatibility to THETOOLS v1.0.7


  • Select Module updated


  • New Logic for Content::compress()
  • Googleanalytics Module allowes $HTML->googleanalytics('UA-0000000-0') for a simple, compressed ga tracker code
  • Added basic Sublime Text 2 snippet


  • fixed bugs related to Store::get()
  • desktop/mobile classes on html tag if THETOOLS are available.


  • callbacks for tags
  • configuration modes
  • bugfixes


  • fixed wp textdomain error


  • if() and endif() pseudotags
  • BasicModule::generate() generates a default tag using the module parameters.
  • When Generator::call is called directly, tag options can now be passed as a third argument in addition to prefix them to the Tag


  • composer update test.


  • composer compatible.
  • now uses composer versions off php-diff and markdown.


  • COMPLETE REMAKE. Most functionality should still work the same way as in 1.x but most likely not everything.
    • Introducing the Xiphe\HTML namespace
    • Better modular OOP Structure
    • Minimalistic Instances + most logic is now static.
    • Tag Instances
    • Test Cases
    • much more...

pre 2.0

  • see changelog.txt


  • The fist line of a multi-lined <li> has a false indention when cleaned with strong mode.


  • radio and checkbox group generation
  • Functionality to add own modules and manipulate the TagInfo Class.
  • More Test Cases
  • Still better documentation
  • Array-style attribute maipulation on Tags would be nice. $Tag[id] = 'myID';