PHPackages                             jjgrainger/html - 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. jjgrainger/html

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

jjgrainger/html
===============

Generate HTML markup with PHP objects

v0.1.0(4y ago)189MITPHPPHP &gt;=7.2

Since May 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jjgrainger/HTML)[ Packagist](https://packagist.org/packages/jjgrainger/html)[ RSS](/packages/jjgrainger-html/feed)WikiDiscussions main Synced 1w ago

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

HTML v0.1.0
===========

[](#html-v010)

[![tests](https://github.com/jjgrainger/html/actions/workflows/tests.yml/badge.svg)](https://github.com/jjgrainger/html/actions/workflows/tests.yml) [![codecov](https://camo.githubusercontent.com/5c6824da429e33d373e48e77d800bc9d477f578d48df74ae82d72673afa305c6/68747470733a2f2f636f6465636f762e696f2f67682f6a6a677261696e6765722f48544d4c2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d424e553250374c50524e)](https://codecov.io/gh/jjgrainger/HTML) [![Latest Stable Version](https://camo.githubusercontent.com/b60ff60927cf5016cf02d97207fe84d472c4f9fb086025017d9cafdfe5eb1ebb/68747470733a2f2f666c61742e62616467656e2e6e65742f6769746875622f72656c656173652f6a6a677261696e6765722f68746d6c2f737461626c65)](https://packagist.org/packages/jjgrainger/html) [![Total Downloads](https://camo.githubusercontent.com/c1511025d7ff02c2bd3c8ae2019cec920933644898d4dbad2c9e65a37aa3eae8/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f6a6a677261696e6765722f68746d6c)](https://packagist.org/packages/jjgrainger/html) [![License](https://camo.githubusercontent.com/7018e408a372b5114b161c2ed1e5f5da30f227e15248b4ea961d39fca1d71b10/68747470733a2f2f666c61742e62616467656e2e6e65742f6769746875622f6c6963656e73652f6a6a677261696e6765722f68746d6c)](https://packagist.org/packages/jjgrainger/html)

> Generate HTML markup with PHP objects

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- [Composer](https://getcomposer.org/)

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

[](#installation)

```
$ composer require jjgrainger/html

```

Usage
-----

[](#usage)

The `Element` class can be used to generate any type of HTML markup.

```
use HTML\Element;

// Creat a link element.
$link = new Element('a');

// Set the href attribute.
$link->setAttribute('href', 'https://google.com');

// Set the class attribute.
$link->setAttribute('class', 'text-link');

// Append attribute values, in this case adding a 'active' class to the element.
$link->appendAttribute('class', 'active');

// Set the content for the
$link->setContent('Hello World!');

// Outputs HTML
echo $link;
```

The above will output the following.

```
Hellow World!
```

Notes
-----

[](#notes)

- The library is still in active development and not intended for production use.
- Licensed under the [MIT License](https://github.com/jjgrainger/html/blob/master/LICENSE)
- Maintained under the [Semantic Versioning Guide](https://semver.org)

Author
------

[](#author)

**Joe Grainger**

-
-

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1461d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e75df324c03b826071d520965956f3bbb8353970080cdfb1c93a742ea0a4ee44?d=identicon)[jjgrainger](/maintainers/jjgrainger)

---

Top Contributors

[![jjgrainger](https://avatars.githubusercontent.com/u/904708?v=4)](https://github.com/jjgrainger "jjgrainger (25 commits)")

---

Tags

htmlhtml5php

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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