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.
Fund package maintenance!
vardumper
Buymeacoffee
www.patreon.com/vardumper
Installs: 106
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 15
Language:TypeScript
pkg:composer/vardumper/extended-htmldocument
Requires
- php: ^8.4
- ext-dom: *
- mnapoli/silly: ^1.9.1
- revolt/event-loop: ^1.0.8
- symfony/yaml: ^5.4|^7.0|^8.0.1
Requires (Dev)
- amphp/file: >=3.2
- brainmaestro/composer-git-hooks: dev-master
- edent/pretty-print-html: 2025-04-18
- friendsofphp/php-cs-fixer: ^3.92.4
- pestphp/pest: ^3.8.4
- pestphp/pest-plugin-drift: ^3.0
- pestphp/pest-plugin-type-coverage: ^3.6.1
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.1.33
- rector/swiss-knife: ^2.3.4
- symfony/http-kernel: ^5.4|^6.0|^7.0|^8.0.3
- symfony/ux-twig-component: ^2.32
- symplify/easy-coding-standard: ^12.6.2
Suggests
- ext-tidy: Required for formatting HTML5 output.
- dev-main
- 0.2.77
- 0.2.76
- 0.2.75
- 0.2.74
- 0.2.73
- 0.2.72
- 0.2.71
- 0.2.70
- 0.2.69
- 0.2.68
- 0.2.67
- 0.2.66
- 0.2.65
- 0.2.64
- 0.2.63
- 0.2.62
- 0.2.61
- 0.2.60
- 0.2.59
- 0.2.58
- 0.2.57
- 0.2.56
- 0.2.55
- 0.2.54
- 0.2.53
- 0.2.52
- 0.2.51
- 0.2.50
- 0.2.49
- 0.2.48
- 0.2.47
- 0.2.46
- 0.2.45
- 0.2.44
- 0.2.43
- 0.2.42
- 0.2.41
- 0.2.40
- 0.2.39
- 0.2.38
- 0.2.37
- 0.2.36
- 0.2.35
- 0.2.34
- 0.2.33
- 0.2.32
- 0.2.31
- 0.2.30
- 0.2.29
- 0.2.28
- 0.2.27
- 0.2.26
- 0.2.25
- 0.2.24
- 0.2.23
- 0.2.22
- 0.2.21
- 0.2.20
- 0.2.19
- 0.2.18
- 0.2.17
- 0.2.16
- 0.2.15
- 0.2.14
- 0.2.13
- 0.2.12
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.27
- 0.1.26
- 0.1.25
- 0.1.24
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feature/refactor-create-class
- dev-copilot/fix-enum-schema-inconsistencies
- dev-feature/twig-component
- dev-feature/codacy-patch
- dev-develop
- dev-copilot/fix-25
- dev-copilot/fix-23
- dev-feature/6-handle-mutliple-attributes-with-same-name-correctly
This package is auto-updated.
Last update: 2026-01-07 11:46:29 UTC
README
Extended HTML Document Library
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
composer require --dev vardumper/extended-htmldocument
TL;DR
This library adds the HTML5 specification to PHP and is fully compatible with DOM\HTMLDocument. You can create an Anchor() object and append it to any DOM\Document.
use Html\Delegator\HTMLDocumentDelegator as HTMLDocument; use Html\Element\Inline\Anchor; $dom = HTMLDocument::createEmpty() echo (string) Anchor::create($dom) ->setClass('secondary') ->setRel(RelEnum::NOFOLLOW) ->setHref('https://google.com') ->setTitle('Google it') ->setContent('Click me'); // output is: // <a class="secondary" href="https://google.com" rel="nofollow" title="Google it">Click me</a>
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 <table><tr><td>Cell</td><tr></table>)
Blade
Blade templates can be found in templates/blade. The README has more infos and usage examples. Blade templates can also be installed via npm with the @typesafe-html5/blade package.
React & NextJS
React and NextJS templates can be found in templates/blade. See the Blade-specific README file for details. Blade templates can also be installed via npm with the @typesafe-html5/react package.
Storybook
Storybook with atoms for all HTML5 elements can be seen in the Demo. Files can be found in templates/storybook. There's also a README with more details.
Storybook for Twig
TBD
Storybook for React/NextJS
TBD
Twig
Twig templates for flexible and performant use with include, embed, and use can be found in templates/twig. See the README for more details and usage examples. Twig templates can also be installed via npm with the @typesafe-html5/twig package.
Twig Components Bundle
Generated, typesafe Twig Components for use with Symfony UXs Twig Components can be found in templates/twig-component. See the README for more details and usage examples. Twig templates can also be installed via the Symfony Bundle vardumper/html5-twig-component-bundle package.
Typescript
Typescript templates can be found in templates/typescript. See the README for more details and usage examples. Typescript templates can also be installed via npm with the @typesafe-html5/typescript package.
Documentation
See the Documentation for more.