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

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

drrago/php-html-generator
=========================

PHP html generator

v1.0.4(11mo ago)0203MITPHPPHP &gt;=8.0

Since Aug 9Pushed 11mo agoCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

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

[](#php-html-generator)

Forked project to support current php coding standards and syntax.

This project is forked from .
Original author:

Create HTML tags and render them efficiently.

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

33

—

LowBetter than 75% of packages

Maintenance50

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.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 ~657 days

Total

2

Last Release

356d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23425f2b5d6c2589893fbdb092c205eed7d8ef6980f16916ec9ba5071eb9448e?d=identicon)[DrRago](/maintainers/DrRago)

---

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)")[![DrRago](https://avatars.githubusercontent.com/u/19204904?v=4)](https://github.com/DrRago "DrRago (4 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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[airmanbzh/php-html-generator

PHP html generator

7973.8k5](/packages/airmanbzh-php-html-generator)[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)
