PHPackages                             airmanbzh/php-html-generator - 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. airmanbzh/php-html-generator

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

airmanbzh/php-html-generator
============================

PHP html generator

v1.0.2(8y ago)7973.8k↑50%29[3 issues](https://github.com/Airmanbzh/php-html-generator/issues)[1 PRs](https://github.com/Airmanbzh/php-html-generator/pulls)5MITPHPPHP &gt;=5.3.0

Since Oct 28Pushed 7y ago7 watchersCompare

[ Source](https://github.com/Airmanbzh/php-html-generator)[ Packagist](https://packagist.org/packages/airmanbzh/php-html-generator)[ Docs](https://github.com/Airmanbzh/php-html-generator)[ RSS](/packages/airmanbzh-php-html-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (5)Used By (5)

PHP HTML GENERATOR
==================

[](#php-html-generator)

Create HTML tags and render them efficiently.

Build status:

- Master [![Build Status](https://camo.githubusercontent.com/e96f5bbf949cac00720718f2e75db86375f46e375e48ef2a603cbd4e62911590/68747470733a2f2f7472617669732d63692e6f72672f4169726d616e627a682f7068702d68746d6c2d67656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Airmanbzh/php-html-generator)
- Dev [![Build Status](https://camo.githubusercontent.com/2e31c868a6bab843727aad85d24be556380747761972bbb23b857e12d4c31de6/68747470733a2f2f7472617669732d63692e6f72672f4169726d616e627a682f7068702d68746d6c2d67656e657261746f722e7376673f6272616e63683d646576)](https://travis-ci.org/Airmanbzh/php-html-generator)

Overview
--------

[](#overview)

```
return HtmlTag::createElement();
// returns an empty HtmlTag Container
```

```
return HtmlTag::createElement('a');
// returns an HtmlTag containing a 'a' tag
```

### Why you should use it

[](#why-you-should-use-it)

- it always generates valid HTML and XHTML code
- it makes templates cleaner
- it's easy to use and fast to execute

Render tags
-----------

[](#render-tags)

```
echo(HtmlTag::createElement('a'));
```

or

```
$tag = HtmlTag::createElement('a')
echo( $tag );
```

### Simple tags

[](#simple-tags)

```
echo HtmlTag::createElement('div');
```

```

```

```
echo(HtmlTag::createElement('p')->text('some content'));
```

```
some content
```

### Structured tags

[](#structured-tags)

```
echo(HtmlTag::createElement('div')->addElement('a')->text('a text'));
```

```
a text
```

```
$container = HtmlTag::createElement('div');
$container->addElement('p')->text('a text');
$container->addElement('a')->text('a link');
```

```
a texta link
```

### Attributes

[](#attributes)

#### Classics attributes (method : 'set')

[](#classics-attributes-method--set)

```
$tag = HtmlTag::createElement('a')
    ->set('href','./sample.php')
    ->set('id','myID')
    ->text('my link');
echo( $tag );
```

```
my link
```

#### Shortcut to set an ID attribute (method : 'id')

[](#shortcut-to-set-an-id-attribute-method--id)

```
$tag = HtmlTag::createElement('div')
    ->id('myID');
echo( $tag );
```

```
my link
```

#### Class management (method : 'addClass'/'removeClass')

[](#class-management-method--addclassremoveclass)

```
$tag = HtmlTag::createElement('div')
    ->addClass('oneClass')
    ->text('my content')
echo( $tag );
```

```
my content
```

```
$tag = HtmlTag::createElement('div')
    ->addClass('aClass')
    ->addClass('anothereClass')
    ->text('my content')
echo( $tag );
```

```
my content
```

```
$tag = HtmlTag::createElement('div')
    ->addClass('firstClass')
    ->addClass('secondClass')
    ->text('my content')
    ->removeClass('firstClass');
echo( $tag );
```

```
my content
```

### More

[](#more)

Text and content are generated according to the order of addition

```
$tag = HtmlTag::createElement('p')
    ->text('a text')
    ->addElement('a')
    ->text('a link');
```

```
ma texta link
```

To generate content before text, 2 solutions :

```
$tag = HtmlTag::createElement('p')
    ->addElement('a')
    ->text('a link')
    ->getParent()
    ->text('a text');
```

or

```
$tag = HtmlTag::createElement('p');
$tag->addElement('a')->text('a link');
$tag->text('a text');
```

```
a linka text
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 80.3% 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 ~262 days

Total

3

Last Release

2964d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1196092?v=4)[Brice LE BOULCH](/maintainers/Airmanbzh)[@Airmanbzh](https://github.com/Airmanbzh)

---

Top Contributors

[![Airmanbzh](https://avatars.githubusercontent.com/u/1196092?v=4)](https://github.com/Airmanbzh "Airmanbzh (53 commits)")[![aduh95](https://avatars.githubusercontent.com/u/14309773?v=4)](https://github.com/aduh95 "aduh95 (8 commits)")[![JustBlackBird](https://avatars.githubusercontent.com/u/1167086?v=4)](https://github.com/JustBlackBird "JustBlackBird (2 commits)")[![effone](https://avatars.githubusercontent.com/u/21265591?v=4)](https://github.com/effone "effone (1 commits)")[![ryanburnette](https://avatars.githubusercontent.com/u/2252601?v=4)](https://github.com/ryanburnette "ryanburnette (1 commits)")[![SmetDenis](https://avatars.githubusercontent.com/u/1118678?v=4)](https://github.com/SmetDenis "SmetDenis (1 commits)")

---

Tags

phpgeneratorhtml

### Embed Badge

![Health badge](/badges/airmanbzh-php-html-generator/health.svg)

```
[![Health](https://phpackages.com/badges/airmanbzh-php-html-generator/health.svg)](https://phpackages.com/packages/airmanbzh-php-html-generator)
```

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[okipa/laravel-form-components

Ready-to-use and customizable form components.

198.0k1](/packages/okipa-laravel-form-components)[tomloprod/radiance

A deterministic mesh gradient avatar generator for PHP.

1393.7k](/packages/tomloprod-radiance)[shish/microhtml

A minimal HTML generating library

1142.1k2](/packages/shish-microhtml)

PHPackages © 2026

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