Download the PHP package vardumper/html5-twig-component-bundle without Composer
On this page you can find all versions of the php package vardumper/html5-twig-component-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vardumper/html5-twig-component-bundle
More information about vardumper/html5-twig-component-bundle
Files in vardumper/html5-twig-component-bundle
Package html5-twig-component-bundle
Short Description Symfony UX Twig Components for typesafe HTML5 elements with ARIA support & enum validation
License MIT
Informations about the package html5-twig-component-bundle
Twig Components for HTML5 Elements
This is a Symfony Bundle which adds pre-built, typesafe, auto-generated Twig Components for all HTML5 elements. It comes with full WCAG, ARIA support, also adds support for Alpine.js attributes. It makes use of Extended HTMLDocument which is a schema-first library that improves HTML5 support in PHP 8.4. Mainly used for validation of immutable enum attributes.
This is especially useful when writing anonymous Twig Components enforcing standards-compliance, always-valid HTML5.
Features
- Symfony UX Integration: Native Symfony Twig Component support
- ARIA Compliant: Complete ARIA attribute support with proper validation
- Auto-Generated: Consistent API across all HTML5 elements via schema-first approach
- Enum Validation: Static attribute validation for HTML compliance
- Modern PHP: Requires PHP 8.4+ for DOM\HTMLDocument features
Requirements
- PHP 8.4 – the underlying Extended HTMLDocument library is built upon PHPs DOM\HTMLDocument which is available since PHP 8.4+
Since only the Enums are used for attribute validation here, adding support for older PHP versions could be done easily if it's needed or requested.
Installation
The bundle includes automatic service registration - no additional configuration needed!
Configuration
When installed via Symfony Flex, this bundle is automatically configured by the recipe in flex/recipe.
If you are not using Symfony Flex, register the bundle manually in config/bundles.php:
Then tell Symfony where the Twig Components are located. Edit config/packages/twig_component.yaml and add the following:
All Twig Components are automatically discovered and registered through the bundle's DependencyInjection extension. No manual service configuration required!
Usage
Use any HTML element as a Twig Component:
Use in anonymous Twig Components
which can then be used in pages:
Passing arrays as component props
You can pass associative arrays to component props using the : notation. For example to pass data-* attributes to the component:
This will render a data-role="article" attribute on the generated component's root element.
Features
- ✅ All HTML5 elements supported
- ✅ Full ARIA attributes support
- ✅ Type-safe enum validation
- ✅ PreMount validation with OptionsResolver
- ✅ Proper namespace structure (Block/Inline/Void)
Components Structure
Components are organized by type:
Block- Block-level elements (div, section, article, etc.)Inline- Inline elements (span, a, strong, etc.)Void- non-rendered elements (head, wbr, meta, etc.)
Read More
- Extended HTMLDocument Documentation
- Extended HTMLDocument Github Repository
- Twig Components
- Symfony UX
Issues & Bugs
Please report issues in this packages home at Extended HTMLDocument
All versions of html5-twig-component-bundle with dependencies
symfony/twig-bundle Version ^5.4|^6.0|^7.0|^8.0.4
symfony/ux-twig-component Version ^2.33
symfony/options-resolver Version ^5.4|^6.0|^7.0|^8.0
vardumper/extended-htmldocument Version ^0.2.82