HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site

2.1.0 2020-11-15 19:56 UTC

This package is auto-updated.

Last update: 2022-08-06 19:14:30 UTC


Version Build Status Made With License Contribution

HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site.


⭐ You like this package? Please star it or send a tweet. ⭐


This package provides a single class to turn a message or HTML-snippet into a valid HTML5 document.

This way it is possible to let an app return an HTML response without the need to store a template file beforehand or initialize a full-blown template engine.

The package therefore does not have template variables or modifiers. Two lines of code should be sufficient to wrap a given text into a valid HTML document. One more to add a link to fancy stylesheet.

See »Usage« for some examples.

The package follows the KISS principle.


This package is used on html5example.com.

If you are in need of an HTML document once only, then you may use a commandline tool like HTTPie and run http https://html5example.com > index.html to save a template file.

The webapp supports some options of this package as well, for example http POST https://html5example.com title=Minimal-Template > index.html to pass a custom title.


  • PHP


Packagist Entry https://packagist.org/packages/pixelbrackets/html5-mini-template/



Mirror https://github.com/pixelbrackets/html5-mini-template/ (Issues & Pull Requests mirrored to GitLab)


⌨️ php tests/demo.php.


  1. Wrap a message into a HTML5 document, return to a PSR-7 implementation

    $template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate();
    $template->setContent('<h1>Status</h1><p>All Systems Operational</p>');
    return $template->getMarkup();
  2. Wrap a message, use a preconfigured CSS framework CDN (see »options« for a list of supported frameworks), and save the document into a file

    $template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate();
    $template->setContent('<h1>Index</h1><p>Nothing to see here</p>');
    file_put_contents('/var/www/example/index.html', $template->getMarkup());
  3. Wrap a message, set your own stylesheet URL, set a title, output the document

    $template = (new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate())
    echo $template->getMarkup();
  4. Get the example template only (👉 or use the Webapp)

    echo \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate::getTemplate();


  • setContent() the message to show, any HTML string to replace the main content of the document
  • setStylesheet() may be a URL to any existing stylesheet or one of following reserved keywords which then creates a link to a CDN of the selected CSS framework
  • setStylesheetMode() either link the given stylesheet (Html5MiniTemplate::STYLE_LINK, default) or fetch its content and print it inline (Html5MiniTemplate::STYLE_INLINE).
  • setTitle() the title is the first headline found in the document, unless it is overwritten with this option
  • setAdditionalMetadata() any additional metadata like metatags or link references, for example a canonical link to avoid duplicate content
    • ⚠️ Usage of this option is an indicator that the given use case is too specific and switching to a template engine like the minimal slim/php-view or the powerfull twig/twig should be considered


GNU General Public License version 2 or later

The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.


Dan Untenzu (mail@pixelbrackets.de / @pixelbrackets)




This script is Open Source, so please use, share, patch, extend or fork it.

Contributions are welcome!


Please send some feedback and share how this package has proven useful to you or how you may help to improve it.