PHPackages                             joaorobertopb/htmlable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. joaorobertopb/htmlable

ActiveLibrary[Templating &amp; Views](/categories/templating)

joaorobertopb/htmlable
======================

Simple PHP library for abstraction and rendering of html elements.

1.1.0(8y ago)2115[1 PRs](https://github.com/joaorobertopb/htmlable/pulls)MITPHPPHP ^5.6 || &gt;=7.0 &lt;7.3

Since Aug 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/joaorobertopb/htmlable)[ Packagist](https://packagist.org/packages/joaorobertopb/htmlable)[ Docs](https://github.com/joaorobertopb/htmlable)[ RSS](/packages/joaorobertopb-htmlable/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Htmlable
========

[](#htmlable)

[![Build Status](https://camo.githubusercontent.com/8033f3eb1bd123cb9cecb65f9a49afe55a388209512c95cb83bbf20380024e22/68747470733a2f2f7472617669732d63692e6f72672f6a6f616f726f626572746f70622f68746d6c61626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/joaorobertopb/htmlable) [![Latest Stable Version](https://camo.githubusercontent.com/fa5460bf2467d9a53abfd32f1d63ae711676a857eb4f49242718524ce1232323/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616f726f626572746f70622f68746d6c61626c652f762f737461626c65)](https://packagist.org/packages/joaorobertopb/htmlable) [![Total Downloads](https://camo.githubusercontent.com/b348f9e0da07f4c4a646dc0169f7d60f6fa23f093247fbf8a56dd55caff4d04b/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616f726f626572746f70622f68746d6c61626c652f646f776e6c6f616473)](https://packagist.org/packages/joaorobertopb/htmlable) [![Latest Unstable Version](https://camo.githubusercontent.com/2ef22729b70e18c50439970298fca834810ebf819534f1ce75f69c6b08da6ccb/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616f726f626572746f70622f68746d6c61626c652f762f756e737461626c65)](https://packagist.org/packages/joaorobertopb/htmlable) [![Code Coverage](https://camo.githubusercontent.com/36d4f7c7c6157f14cda093e6584d03a8e92d597d4a7c1749e085a3c4adf5d4e4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f616f726f626572746f70622f68746d6c61626c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/joaorobertopb/htmlable/?branch=master) [![Quality Score](https://camo.githubusercontent.com/824d581b15cdb651677945faa9b89943423fc8eee8b45a5421c46d628e3a3a84/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a6f616f726f626572746f70622f68746d6c61626c652e737667)](https://scrutinizer-ci.com/g/joaorobertopb/htmlable) [![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)

Simple PHP library for abstraction and rendering of html elements.

Install
-------

[](#install)

Via Composer

```
$ composer require joaorobertopb/htmlable
```

Usage
-----

[](#usage)

```
$div = new JoaoRobertoPB\Htmlable\Tag('div');
$div->add('Hello, Htmlable!');
$div->render();
```

- The html code will be printed by the method`render()`.
- To return the html code use the `toHtml()` method.

Examples
--------

[](#examples)

An empty tag:

```
$div = new Tag('div'); // Or $div = Tag::make('div');
$div->render();
```

```

```

A plain tag with text contents:

```
$h1 = new Tag('h1');
$h1->add("Header");
$h1->render();
```

```
Header
```

A tag with multiple attributes:

```
$a = new Tag('a');
$a->id = "example";
$a->href = "#";
$a->add("Link");
$a->render();

//Or attributes via construct method

$a = new Tag('a',['id'=>"example", 'href'=>"#"]);
$a->add("Link");
$a->render();
```

```
Link
```

A more complex structure:

```
$div = new Tag('div',['class'=>"container"]);
$divRow = new Tag('div',['class'=>"row"]);
$divCol = new Tag('div',['class'=>"col-md-6"]);

$divCol->add("Hello!");
$divRow->add($divCol);
$div->add($divRow);

$div->render();
```

```

      Hello!

```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [João Roberto](https://github.com/joaorobertopb)
- [All Contributors](../../contributors)

This package is inspired by [this](http://www.adianti.com.br/phpoo) great book by [@pablodalloglio](https://github.com/pablodalloglio). Here is a [package](https://github.com/spatie/html-element) I used as reference.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~276 days

Total

2

Last Release

2952d ago

PHP version history (2 changes)1.0.0PHP ~5.6|~7.0

1.1.0PHP ^5.6 || &gt;=7.0 &lt;7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/070d4c9402e25d53f88b30cbfe28e2f9e6a316bddc123e85bc37c8e853e27750?d=identicon)[joaorobertopb](/maintainers/joaorobertopb)

---

Top Contributors

[![joaorobertopb](https://avatars.githubusercontent.com/u/6556083?v=4)](https://github.com/joaorobertopb "joaorobertopb (25 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (1 commits)")

---

Tags

htmljoaorobertopbhtmlable

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/joaorobertopb-htmlable/health.svg)

```
[![Health](https://phpackages.com/badges/joaorobertopb-htmlable/health.svg)](https://phpackages.com/packages/joaorobertopb-htmlable)
```

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.6k37.4M222](/packages/phpoffice-phpword)[latte/latte

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.

1.3k16.2M755](/packages/latte-latte)[twig/string-extra

A Twig extension for Symfony String

22149.2M215](/packages/twig-string-extra)[exercise/htmlpurifier-bundle

HTMLPurifier integration for your Symfony project

28012.1M19](/packages/exercise-htmlpurifier-bundle)[twig/markdown-extra

A Twig extension for Markdown

12115.5M122](/packages/twig-markdown-extra)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7528.4M261](/packages/laminas-laminas-view)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
