Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Html Laravel Package

yiisoft/html

Yii HTML provides tools for dynamic server-side HTML generation in PHP: a dedicated class for each tag, a CustomTag class, widgets like ButtonGroup, CheckboxList and RadioList, automatic encoding with NoEncode, and an Html helper for creating tags and widgets. Requires PHP 8.1–8.5.

View on GitHub
Deep Wiki
Context7

Handy library to generate HTML

Frequently asked questions about Html
What is yiisoft/html and can I use it in a Laravel app?
yiisoft/html is a framework-agnostic Composer library for server-side HTML generation in PHP. It gives you a dedicated class per tag (A, Code, Form, Img, P, Select and more), a CustomTag class for arbitrary tags, the ButtonGroup, CheckboxList and RadioList widgets, automatic HTML encoding with a NoEncode escape hatch, and a static Html helper. It has no Laravel coupling at all: no service provider, no config file, no facade, no container dependency. That means it is a renderer, not a view layer, and it sits alongside Blade rather than replacing it.
How do I install yiisoft/html in a Laravel project?
Run composer require yiisoft/html and you are done. There is no config to publish, no migration, no middleware and no asset step, because the package only turns PHP values into HTML strings. From there you either call the static Html helper or instantiate tag classes directly inside a controller, view composer, job, mail builder or Blade template.
Which PHP and Laravel versions does yiisoft/html support?
The README states PHP 8.1 through 8.5, which lines up with the PHP floors of Laravel 10, 11 and 12. The package constrains PHP rather than any framework, so your Laravel version requirement comes from the application, not from this dependency. Confirm the current constraint against Packagist before you lock it into composer.json.
Does yiisoft/html replace Blade in Laravel?
No, and treating it as a Blade replacement is the wrong migration to propose. It emits strings, so you consume it inside Blade with a raw echo, a @php block, or a custom directive that wraps your Html:: calls. The README itself says that for simple static HTML it is preferable to write HTML directly, so its value is in data-driven output such as forms, admin tables, email bodies and reusable widget packages.
How does yiisoft/html handle HTML encoding and XSS?
All tag content is HTML-encoded automatically, so normal usage is safe by default. The escape hatches are the NoEncode wrapper class and encode(false) on tags, and every one of those calls is a deliberate XSS boundary that must be reviewable in code review. A sensible Laravel integration wraps the library behind your own builder or directive so NoEncode usage is centralized and easy to audit.
How do I build checkbox lists, radio lists and button groups with yiisoft/html?
Use the Html helper or the widget classes directly: CheckboxList and RadioList take an array of options and produce grouped inputs, and ButtonGroup renders grouped buttons with consistent markup. They are a good fit when your options come from the database or config rather than from hand-written markup. Keep in mind the widgets know nothing about Laravel's old() input or validation error bags, so you have to pass checked state and error classes in yourself.
Do I need the Yii framework to use yiisoft/html?
No. It is a PSR-4 Composer library with no container, no facades, no service providers and no Yii runtime coupling in the documented surface. The caveat is cultural rather than technical: the roadmap follows Yii 3.x, and the surrounding support community (Yii Forum, Telegram, Slack) will not overlap with what your Laravel engineers already know. Budget onboarding time for the class-per-tag mindset instead of Blade components and Form facades.
Why does yiisoft/html generate different IDs each request, and how do I test the output?
Html::generateId() seeds from hrtime(true), so IDs are non-deterministic and will break snapshot and DOM-assertion tests. The package documents disableSeed() test helpers that make generation predictable, and you can also pass explicit id attributes at call sites. Treat this as a test-infrastructure tax and prove it out during the pilot rather than discovering it in CI later.
Is yiisoft/html actively maintained and safe to adopt in production?
The engineering hygiene is strong: Psalm static analysis with published level and type-coverage badges, Infection mutation testing, Rector, composer-require-checker, a changelog and tagged releases. Market validation is weak by comparison, with roughly 59 GitHub stars and zero dependents on Packagist, which means you would be an early production adopter absorbing discovery risk. Verify the last release date on Packagist before committing, since intake data showed a suspicious future date. The license is BSD-3-Clause, which is permissive and Laravel-compatible.
What are the alternatives to yiisoft/html for generating HTML in Laravel?
The mainstream options are Blade components and slots, spatie/laravel-html, and the older Laravel Collective HTML helpers. yiisoft/html competes on object-oriented tag construction with automatic context-aware encoding and a strict separation between encoded and NoEncode content. Pick it when you want a framework-neutral renderer you can share with non-Laravel code or when Blade feels awkward for programmatic forms, not when you simply want tidier templates for static pages.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style