PHPackages                             vardumper/extended-htmldocument - 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. vardumper/extended-htmldocument

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

vardumper/extended-htmldocument
===============================

ExtendedHTMLDocument is a simple PHP library which adds all HTML5 Elements as PHP classes and extends PHP 8.4's DOM\\HTMLDocument class.

0.3.5(2w ago)94122[6 issues](https://github.com/vardumper/extended-htmldocument/issues)1MITPHPPHP ^8.4CI passing

Since Feb 23Pushed 2w ago1 watchersCompare

[ Source](https://github.com/vardumper/extended-htmldocument)[ Packagist](https://packagist.org/packages/vardumper/extended-htmldocument)[ Docs](https://github.com/vardumper/extended-htmldocument)[ Fund](https://www.buymeacoffee.com/vardumper)[ Fund](https://www.patreon.com/vardumper)[ RSS](/packages/vardumper-extended-htmldocument/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (65)Versions (146)Used By (1)

   [ ![HTML5 Logo](https://camo.githubusercontent.com/185b17ed7395c5e9653b77d25dba60b91bb62aeaf48b512a30f9e068ccc8580a/68747470733a2f2f76617264756d7065722e6769746875622e696f2f657874656e6465642d68746d6c646f63756d656e742f68746d6c355f6c6f676f2d776974682d776f72646d61726b2e737667) ](https://www.w3.org/TR/2011/WD-html5-20110405/)   [ ![PHP Logo](https://camo.githubusercontent.com/0a89cb53814a821091bbfe9c4642e90eb7a9cc4873990dc807bb8338eaeadec7/68747470733a2f2f76617264756d7065722e6769746875622e696f2f657874656e6465642d68746d6c646f63756d656e742f66696c655f747970655f706870332e737667) ](https://www.php.net/manual/de/class.dom-htmldocument.php)  Extended HTML Document Library
==============================

[](#extended-html-document-library)

 [ ![](https://camo.githubusercontent.com/f59786c0e02eeb7a787cb7ce653f58cbc4a126b5374971ba9f1a1ac9d4e9a705/68747470733a2f2f64747261636b2e6572696b706f65686c65722e75732f6170692f76312f62616467652f76756c6e732f70726f6a6563742f33373237393535332d306334372d343736612d396566642d6564333739666162636131613f6170694b65793d6f64745f6e473833575f454163515a6b6b3662354b716b6e49566f4b386e664e6a537a33384f6d706e6e) ](https://dtrack.erikpoehler.us/projects/37279553-0c47-476a-9efd-ed379fabca1a)[![Static Badge](https://camo.githubusercontent.com/0395833017ab75581633c6828b2a15a3e2b8146edfd2fc916b8c4dab59859441/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e697425323074657374732d70617373696e672d677265656e3f7374796c653d666c617426636f6c6f723d253233346331)](https://camo.githubusercontent.com/0395833017ab75581633c6828b2a15a3e2b8146edfd2fc916b8c4dab59859441/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e697425323074657374732d70617373696e672d677265656e3f7374796c653d666c617426636f6c6f723d253233346331)[![Code Coverage](https://github.com/vardumper/extended-htmldocument/raw/main/coverage.svg)](https://vardumper.github.io/extended-htmldocument/unit-tests)[![Latest Stable Version](https://camo.githubusercontent.com/f0ea27fa2c20e81d786e2317d886a9ce6abf5948f3e666d34ff35d4d7f26efce/68747470733a2f2f706f7365722e707567782e6f72672f76617264756d7065722f657874656e6465642d68746d6c646f63756d656e742f762f737461626c65)](https://packagist.org/packages/vardumper/extended-htmldocument)[![Total Downloads](https://camo.githubusercontent.com/d94dac4925a74bfbe6577d497be10251d245540ff43c18d7c9a4ac368ec074a6/68747470733a2f2f706f7365722e707567782e6f72672f76617264756d7065722f657874656e6465642d68746d6c646f63756d656e742f646f776e6c6f616473)](https://packagist.org/packages/vardumper/extended-htmldocument)

This library provides a way to work with HTML elements in PHP, offering an object-oriented approach that aligns with the HTML5 specifications. It also provides a way to automatically transform HTML into different templating engines or code for frontend frameworks. It also adds autocompletion to PHP for all HTML5 elements, which is especially useful when working with DOM Documents. It adds additional functionality and a stronger focus on HTML5 while being fully compatible with PHP's DOM\\HTMLDocument and DOM\\HTMLElement classes.

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

[](#installation)

```
composer require --dev vardumper/extended-htmldocument
```

TL;DR
-----

[](#tldr)

This library adds the HTML5 specification to PHP and is fully compatible with `DOM\HTMLDocument`. You can now instantiate an `Anchor` without passing a document.

```
use Html\Element\Inline\Anchor;
use Html\Enum\RelEnum;

echo (new Anchor())
    ->setClass('secondary')
    ->setRel(RelEnum::NOFOLLOW)
    ->setHref('https://google.com')
    ->setTitle('Google it')
    ->setContent('Click me');
// produces: Click me
```

Generated Templates
-------------------

[](#generated-templates)

Templates are generated from the HTML5 schema for every HTML element. These allow for better consistency in your design system(s), support all possible HTML attributes and have basic validations for enum attributes. Files are grouped into inline, block and void elements. For elements with a specific content model, a composed template is generated as well. (eg `Cell`)

### Blade

[](#blade)

Blade templates can be found in [`templates/blade`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/blade). The [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/blade/README.md) has more infos and usage examples. Blade templates can also be installed via `npm` with the [@typesafe-html5/blade](https://www.npmjs.com/package/@typesafe-html5/blade) package.

Each element's template is generated as `index.blade.php` inside a subdirectory named after the element (e.g. `blade/block/div/index.blade.php`), which Blade resolves as `x-block.div`.

The `blade-component` generator converts a full YAML component definition into a Blade document using ``, `` and `` component tags. Use it via the `watch` command — see the [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/blade/README.md) for examples.

### React &amp; NextJS

[](#react--nextjs)

React and NextJS templates can be found in [`templates/nextjs`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/nextjs). See the [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/nextjs/README.md) file for details. NextJS templates can also be installed via `npm` with the [@typesafe-html5/react](https://www.npmjs.com/package/@typesafe-html5/react) package.

### Storybook

[](#storybook)

Storybook with atoms for all HTML5 elements can be [seen in the Demo](https://vardumper.github.io/extended-htmldocument/storybook-site/). Files can be found in [`templates/storybook`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/storybook). There's also a [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/storybook/README.md) with more details.

### Storybook for Twig

[](#storybook-for-twig)

TBD

### Storybook for React/NextJS

[](#storybook-for-reactnextjs)

TBD

### Twig

[](#twig)

Twig templates for flexible and performant use with `include`, `embed`, and `use` can be found in [`templates/twig`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/twig). See the [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/twig/README.md) for more details and usage examples. Twig templates can also be installed via `npm` with the [@typesafe-html5/twig](https://www.npmjs.com/package/@typesafe-html5/twig) package.

### Twig Components Bundle

[](#twig-components-bundle)

Generated, typesafe Twig Components for use with Symfony UXs Twig Components can be found in [`templates/twig-component`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/twig-component). See the [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/twig-component/README.md) for more details and usage examples. Twig templates can also be installed via the Symfony Bundle [vardumper/html5-twig-component-bundle](https://github.com/vardumper/html5-twig-component-bundle) package.

### Typescript

[](#typescript)

Typescript templates can be found in [`templates/typescript`](https://github.com/vardumper/extended-htmldocument/tree/main/templates/typescript). See the [README](https://github.com/vardumper/extended-htmldocument/blob/main/templates/typescript/README.md) for more details and usage examples. Typescript templates can also be installed via `npm` with the [@typesafe-html5/typescript](https://www.npmjs.com/package/@typesafe-html5/typescript) package.

Documentation
-------------

[](#documentation)

See the [Documentation](https://vardumper.github.io/extended-htmldocument/) for more.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance83

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~4 days

Total

132

Last Release

15d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21208397?v=4)[Erik Pöhler](/maintainers/vardumper)[@vardumper](https://github.com/vardumper)

---

Top Contributors

[![vardumper](https://avatars.githubusercontent.com/u/21208397?v=4)](https://github.com/vardumper "vardumper (346 commits)")[![iroybotlinio](https://avatars.githubusercontent.com/u/14099768?v=4)](https://github.com/iroybotlinio "iroybotlinio (323 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (127 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

bladedesign-systemhtmlhtml5nextjsphpreacttwigtypescriptphpcode generatorhtmlHTML5domextendeddocumentcode-generationphp8php84htmldocument

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vardumper-extended-htmldocument/health.svg)

```
[![Health](https://phpackages.com/badges/vardumper-extended-htmldocument/health.svg)](https://phpackages.com/packages/vardumper-extended-htmldocument)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[ressio/pharse

Fastest PHP HTML Parser

8684.0k](/packages/ressio-pharse)[epic-64/elem

A fluent, type-safe PHP library for building HTML documents using the DOM

2815.0k](/packages/epic-64-elem)

PHPackages © 2026

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