Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Set of php classes for HTML generation
Branch: master
Failed to load latest commit information.
nbproject unittests
tests namespacing
.gitignore first commit
.travis.yml 5.3
LICENSE first commit
README first commit
phpunit.xml travis

yuki-html project status

Build Status

Efficient way to create and modify HTML tags.

Why you should use it

Sometimes you need to return html tag from class, and be able to modify it later:


    class myImage{
        public static function getHtml(){
            return '<img src="myimage.png" />';
    $img = myImage::getHtml();
    // I wanna add alt and style attributes before output, but how I can?
    echo $img;

So, How?


    use yuki\html\tag;
    class myImage{
        public static function getHtml(){
            return tag::create('img', array('src' => 'myimage.png'));
    $img = myImage::getHtml();

Now you can do what you want:


    $img['alt'] = 'My Image!';
    $img['style'] = "border: none;";
    echo $img; // <img src="myimage.png" alt="My Image!" style="border: none;" />

You even able to get attributes


    echo $img['src']; // myimage.png

To remove attributes


    echo $img; // <img src="myimage.png" alt="My Image!" />

To wrap


    use yuki\html\tag;
    $a = tag::create('a', array('href'=>'/'));
    echo $a; // <a href="/"><img src="myimage.png" alt="My Image!" /></a>

To set text, it will be escaped!


    $a->setText('click here >>');
    echo $a; // <a href="/">click here &gt;&gt;</a>



    use yuki\html\tag;
    $head = tag::create('head');
            tag::create('title')->setText('Page Title')
            tag::create('meta', array(
                'contents' => 'Page Description'
    $head['lang'] = 'en';
    echo $head; // Will output generated html code.



  • Any flavor of PHP 5.3 should do
  • [optional] PHPUnit 3.5+ to execute the test suite (phpunit --version)

Submitting bugs and feature requests

Bugs and feature request are tracked on Github


olamedia -
See also the list of contributors which participated in this project.


yuki-html is licensed under the MIT License - see the LICENSE file for details


This library is inspired by symfony (TagHelper), kohana (HTML) and other frameworks

Something went wrong with that request. Please try again.