cyberwolf888 / html
HTML and Form Builders for the Laravel Framework
8.0.0
2025-05-26 07:51 UTC
Requires
- php: >=8.2
- illuminate/http: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/routing: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/session: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/view: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- illuminate/database: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
- mockery/mockery: ~1.0
- phpunit/phpunit: ~8.5|^9.5.10|^10.0|^11.0|^12.0
README
HTML and Form Builders for the Laravel Framework โ a maintained fork of LaravelCollective/html.
โจ Features
- ๐๏ธ Form Builder โ open/close forms, model binding, CSRF tokens, and all input types
- ๐ HTML Builder โ generate links, scripts, styles, lists, images, meta tags, and more
- โก Macro & Component support โ extend both builders with your own methods
- ๐ Laravel auto-discovery โ no manual provider/alias registration needed
- ๐งช Laravel 6โ12 compatible with PHP 8.2+
๐ฆ Installation
composer require cyberwolf888/html
Laravel's auto-discovery will register the service provider and facades automatically.
If you prefer manual registration, add to config/app.php:
'providers' => [ Collective\Html\HtmlServiceProvider::class, ], 'aliases' => [ 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, ],
๐ Usage
Form Builder
{{-- Open a form --}} {!! Form::open(['url' => '/login', 'method' => 'POST']) !!} {{-- Model-bound form --}} {!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'PUT']) !!} {{-- Common inputs --}} {!! Form::label('email', 'E-Mail Address') !!} {!! Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'you@example.com']) !!} {!! Form::label('password', 'Password') !!} {!! Form::password('password', ['class' => 'form-control']) !!} {!! Form::label('role', 'Role') !!} {!! Form::select('role', ['admin' => 'Admin', 'user' => 'User'], 'user') !!} {!! Form::checkbox('remember', 1, true) !!} Remember me {!! Form::submit('Login', ['class' => 'btn btn-primary']) !!} {!! Form::close() !!}
Available Form Methods
| Method | Description |
|---|---|
Form::open() / Form::close() |
Open and close a form tag |
Form::model($model, $options) |
Model-bound form |
Form::token() |
CSRF hidden input |
Form::label($name, $value) |
Label element |
Form::text/email/password/number/... |
Standard text inputs |
Form::textarea($name) |
Textarea |
Form::select($name, $list) |
Select dropdown |
Form::selectRange/selectYear/selectMonth |
Range/year/month selects |
Form::checkbox/radio |
Checkbox and radio inputs |
Form::file($name) |
File upload input |
Form::submit/button/reset |
Submit, button and reset |
Form::hidden($name, $value) |
Hidden input |
Form::date/time/datetime/... |
Date/time inputs |
Form::color/range/search/tel/url/week |
Specialized HTML5 inputs |
Form::datalist($id, $list) |
Datalist element |
HTML Builder
{{-- Scripts and styles --}} {!! Html::script('js/app.js') !!} {!! Html::style('css/app.css') !!} {{-- Links --}} {!! Html::link('https://example.com', 'Visit Site', ['class' => 'btn']) !!} {!! Html::linkRoute('home', 'Home') !!} {!! Html::mailto('hello@example.com', 'Contact Us') !!} {{-- Images --}} {!! Html::image('img/logo.png', 'Logo', ['width' => 100]) !!} {!! Html::favicon('img/favicon.ico') !!} {{-- Lists --}} {!! Html::ul(['Apple', 'Banana', 'Cherry']) !!} {!! Html::ol(['First', 'Second', 'Third']) !!} {{-- Meta tags --}} {!! Html::meta('description', 'My awesome page') !!} {{-- Arbitrary tag --}} {!! Html::tag('span', 'Hello', ['class' => 'badge']) !!}
Macros
Extend either builder with custom macros:
// AppServiceProvider::boot() Form::macro('phone', function ($name, $value = null, $options = []) { return Form::tel($name, $value, array_merge(['pattern' => '[0-9]{10,15}'], $options)); }); Html::macro('badge', function ($text, $class = 'primary') { return new \Illuminate\Support\HtmlString( "<span class=\"badge badge-{$class}\">{$text}</span>" ); });
๐ค Contributing
Please read CONTRIBUTING.md before submitting pull requests.
๐ License
This package is open-sourced software licensed under the MIT license.