PHPackages                             validaide/html-builder - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. validaide/html-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

validaide/html-builder
======================

PHP Library providing a fluent interface to generate small snippets of HTML

7.8.0(6mo ago)063.8k↓37.2%1[1 issues](https://github.com/validaide/html-builder/issues)[3 PRs](https://github.com/validaide/html-builder/pulls)1MITPHPPHP ^8.4CI passing

Since Sep 25Pushed 2mo agoCompare

[ Source](https://github.com/validaide/html-builder)[ Packagist](https://packagist.org/packages/validaide/html-builder)[ RSS](/packages/validaide-html-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (69)Used By (1)

Validaide HtmlBuilder
=====================

[](#validaide-htmlbuilder)

Validaide's HTML builder is a small library with a fluent interface to generate snippets of HTML code.

Introduction
------------

[](#introduction)

Alright, so some might say: *"Why in God's name would you need such a thing!?"*. And indeed, we have, I don't know, awesome stuff like [Twig](https://twig.symfony.com/), right!? And you are right! I ❤️ Twig! But in turns out our code base still finds itself with small helper methods that generate tiny snippets of HTML.

Take the example below:

```
public function userStateToIcon(User $user): string
{
  return sprintf('', strtolower($user->getState()), $user->getId(), $user->getUsername()):
}
```

Now, despite that the above can be optimized still, the last return statement is the one we are trying to simplify:

```
public function userStateToIcon(User $user): HTMLTag
{
  return HTML::create('span')
          ->class(strtolower($user->getState())
          ->id($user->getId())
          ->attr('data-username',$user->getUsername());
}
```

Now, in number of characters written, it is not necessarily faster, but it will ensure:

1. Valid HTML is generated
2. Safe HTML is generated
3. Easier modification of the 'HTML' being built afterwards

Installation
------------

[](#installation)

Our big friend [Composer](https://getcomposer.org/) to the rescue using [Packagist](https://packagist.org/) of course:

```
composer require validaide/html-builder

```

❤️ Composer ❤️ Packagist

Examples
--------

[](#examples)

1. Plain tag: ```
    HTML::create('span')
    ```

    ```

    ```
2. Plain tag with content: ```
    HTML::create('h1')->text('Heading 1');
    ```

    ```
    Heading 1
    ```
3. Nested tags: ```
    HTML::create('div')->id('div-1)->tag('div')->id('div-2);
    ```

    ```

    ```

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance79

Regular maintenance activity

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity94

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 59.7% 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 ~45 days

Recently: every ~97 days

Total

58

Last Release

180d ago

Major Versions

2.5.0 → 3.0.02020-06-24

3.7.0 → 4.0.02021-05-26

4.7.0 → 5.0.02022-04-22

5.9.0 → 6.0.02023-10-02

6.2.0 → 7.0.02024-04-22

PHP version history (7 changes)0.1.0PHP ^7.0

1.8.0PHP ^7.2

3.6.0PHP ^7.4

5.3.2PHP ^8.0|^7.4

5.6.0PHP ^7.4 | ^8.1

5.8.0PHP ^8.1

7.8.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/40be841dd08fa5131aff7666525f65b7fdc0ca8bf1c1d50c9dba5e3b25fb3a89?d=identicon)[validaide](/maintainers/validaide)

---

Top Contributors

[![validaide-devops](https://avatars.githubusercontent.com/u/21339130?v=4)](https://github.com/validaide-devops "validaide-devops (179 commits)")[![validaide-mark-bijl](https://avatars.githubusercontent.com/u/23452916?v=4)](https://github.com/validaide-mark-bijl "validaide-mark-bijl (48 commits)")[![validaide-cristian-navalici](https://avatars.githubusercontent.com/u/96288590?v=4)](https://github.com/validaide-cristian-navalici "validaide-cristian-navalici (33 commits)")[![validaide-marcel-tuinstra](https://avatars.githubusercontent.com/u/23452880?v=4)](https://github.com/validaide-marcel-tuinstra "validaide-marcel-tuinstra (15 commits)")[![validaide-amshu-kanth](https://avatars.githubusercontent.com/u/85110225?v=4)](https://github.com/validaide-amshu-kanth "validaide-amshu-kanth (12 commits)")[![validaide-marian-miczka](https://avatars.githubusercontent.com/u/39262288?v=4)](https://github.com/validaide-marian-miczka "validaide-marian-miczka (10 commits)")[![validaide-yakup-arslan](https://avatars.githubusercontent.com/u/165403958?v=4)](https://github.com/validaide-yakup-arslan "validaide-yakup-arslan (1 commits)")[![validaide-gianluigi-disconzi](https://avatars.githubusercontent.com/u/213033820?v=4)](https://github.com/validaide-gianluigi-disconzi "validaide-gianluigi-disconzi (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/validaide-html-builder/health.svg)

```
[![Health](https://phpackages.com/badges/validaide-html-builder/health.svg)](https://phpackages.com/packages/validaide-html-builder)
```

###  Alternatives

[alibabacloud/sdk

Alibaba Cloud SDK for PHP - Easier to Use Alibaba Cloud in your PHP project

5282.1M45](/packages/alibabacloud-sdk)

PHPackages © 2026

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