souravmsh/laravel-html
Composer 安装命令:
composer require souravmsh/laravel-html
包简介
HTML and Form Builders for Laravel
README 文档
README
A lightweight HTML and Form Builders library for Laravel.
Motivation & History
For years, the laravelcollective/html package was standard for managing forms and HTML in Laravel applications. However, as Laravel progressed into newer major releases, the laravelcollective/html package was deprecated and stopped receiving support.
This presented a significant upgrade hurdle: legacy codebases with hundreds of forms utilizing the Form:: facade would require massive refactoring efforts just to upgrade the core Laravel framework.
Laravel HTML Form was built to solve this exact problem. It serves as a custom, lightweight, drop-in replacement that precisely mimics the API and core features of the original laravelcollective/html package. By simply installing this library, you can safely upgrade your project to modern Laravel versions without needing to rewrite a single line of your existing Blade templates!
Features
- Seamless drop-in replacement for legacy syntax
- Compatible with Laravel 10.x, 11.x, 12.x and 13.x
- Automatic CSRF Token injection
- Automatic method spoofing (
PUT,PATCH,DELETE) - Form Model Binding (including nested
dot.notationelements) - Supports repopulating with
old()session inputs
Installation
composer require souravmsh/laravel-html
Quick Start
This package provides the Form facade which allows you to build HTML forms easily.
Opening a Form
{!! Form::open(['url' => 'foo/bar']) !!} // {!! Form::close() !!}
Using Named Routes:
{!! Form::open(['route' => 'route.name']) !!}
Using Controller Actions:
{!! Form::open(['action' => 'Controller@method']) !!}
Specifying the Method:
By default, forms using the open method will use POST. You can customize this:
{!! Form::open(['url' => 'foo/bar', 'method' => 'put']) !!}
Note: Since HTML forms only support
POSTandGET,PUT,PATCHandDELETEwill be spoofed by automatically adding a_methodhidden field to your form.
File Uploads:
If your form includes file uploads, add a files option:
{!! Form::open(['url' => 'foo/bar', 'files' => true]) !!}
Model Binding
You can populate forms automatically using model binding. It automatically gets values from old() session inputs and falls back to attributes of your model instance. It also supports dot notation formatting for array inputs like address.city.
{!! Form::model($user, ['route' => ['user.update', $user->id], 'method' => 'put']) !!} {!! Form::text('name') !!} {!! Form::close() !!}
Labels & Inputs
Labels
{!! Form::label('email', 'E-Mail Address', ['class' => 'control-label']) !!}
Text, Email & Password
{!! Form::text('username', null, ['class' => 'form-control']) !!} {!! Form::email('email', null, ['class' => 'form-control']) !!} {!! Form::password('password', ['class' => 'form-control']) !!}
Note: Password inputs do not prepopulate from old input or model binding.
Other Inputs
{!! Form::number('age', null, ['class' => 'form-control']) !!} {!! Form::date('birthdate', null, ['class' => 'form-control']) !!} {!! Form::url('website_url', null, ['class' => 'form-control']) !!} {!! Form::hidden('invisible', 'secret') !!}
Textarea
{!! Form::textarea('description', null, ['class' => 'form-control', 'rows' => 3]) !!}
File Uploads
{!! Form::file('avatar', ['class' => 'form-control-file']) !!}
Checkboxes and Radio Buttons
{!! Form::checkbox('name', 'value', true) !!} <!-- true sets it as checked --> {!! Form::radio('name', 'value', true) !!}
Dropdown Lists (Select)
You may pass an array (or a collection) into the select method:
{!! Form::select('size', ['L' => 'Large', 'S' => 'Small'], 'S', ['placeholder' => 'Select a size']) !!}
Grouped Lists:
{!! Form::select('animal', [ 'Cats' => ['leopard' => 'Leopard'], 'Dogs' => ['spaniel' => 'Spaniel'], ], null) !!}
Buttons
{!! Form::submit('Submit Now', ['class' => 'btn btn-primary']) !!} {!! Form::button('Click Me', ['class' => 'btn btn-secondary', 'type' => 'button']) !!}
Helper Functions
In addition to the Form facade, this package also provides a form() global helper function. This is especially useful if you prefer function-based syntax over static facade method calls.
{!! form()->open(['url' => 'foo/bar']) !!} {!! form()->text('name', null, ['class' => 'form-control']) !!} {!! form()->close() !!}
Extending / Macros
Since the underlying FormBuilder uses the Macroable trait, you can easily register your own custom methods:
Form::macro('myField', function() { return '<input type="awesome">'; });
Then use it via:
{!! Form::myField() !!}
License
This package is open-source software licensed under the MIT license.
souravmsh/laravel-html 适用场景与选型建议
souravmsh/laravel-html 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「html」 「contact」 「builder」 「laravel」 「html-form」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 souravmsh/laravel-html 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 souravmsh/laravel-html 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 souravmsh/laravel-html 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
HTML and form generation
A Laravel Filament Forms slug field.
A jQuery augmented PHP library for creating and validating HTML forms
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-15