PHPackages                             laraveldaily/laravel-html - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. laraveldaily/laravel-html

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laraveldaily/laravel-html
=========================

A fluent html builder

3.2(3y ago)21411MITPHPPHP ^7.4|^8.0

Since Jan 24Pushed 3y agoCompare

[ Source](https://github.com/LaravelDaily/laravel-html)[ Packagist](https://packagist.org/packages/laraveldaily/laravel-html)[ Docs](https://github.com/spatie/laravel-html)[ RSS](/packages/laraveldaily-laravel-html/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (71)Used By (0)

Painless html generation
========================

[](#painless-html-generation)

[![Latest Version on Packagist](https://camo.githubusercontent.com/09663685a7f9cb51d9c329d50747ec338a90767ad3f590f99b1ca3bf6d9c190b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d68746d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-html)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/7783c5272dd24c40e93f3c46a043ca657fe576f5e07775fd05abf8077435f435/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d68746d6c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-html)[![Quality Score](https://camo.githubusercontent.com/c5db949750e3e4c637dcc12eb07ddfa464251022f6720752990373615aa485ad/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d68746d6c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-html)[![StyleCI](https://camo.githubusercontent.com/bb4be44e746075ff45b258d67f75e112fc8a7dd892b90b47a351ed17063335c2/68747470733a2f2f7374796c6563692e696f2f7265706f732f37383131343036322f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/78114062)[![Total Downloads](https://camo.githubusercontent.com/5cb46e62d5dcb90797bcd6d69db46f0fb28fb9993ece0588cb939ae8bca24a84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d68746d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-html)

This package helps you generate HTML using a clean, simple and easy to read API. All elements can be dynamically generated and put together. The HTML builder helps you generate dynamically assigned form elements based on your selected model, the session or a default value.

### Documentation

[](#documentation)

You'll find full documentation [here](https://docs.spatie.be/laravel-html).

### Upgrading to 2.0

[](#upgrading-to-20)

Version 2.0 was tagged because it could break some very specific cases, but you most likely don't have any work upgrading! Check out ["Upgrading"](#upgrading) for a detailed explanation.

### Generating elements

[](#generating-elements)

For example creating a new `span` element with a class is super easy with the [fluent methods for elements](https://docs.spatie.be/laravel-html/v1/general-usage/element-methods):

```
html()->span()->text('Hello world!')->class('fa fa-eye');
```

### Building forms

[](#building-forms)

Here's a quick example that builds a basic form with an e-mail input:

```
{{ html()->form('PUT', '/post')->open() }}

{{ html()->email('email')->placeholder('Your e-mail address') }}

{{ html()->form()->close() }}
```

The generated HTML will look like this:

```

```

Notice how the hidden `_method` and `_token` fields were automatically added and filled? You'll never forget to add `csrf_field()` again because now you simply wont have to anymore!

Another common use case might be to fill an input element based on the value that was previously submitted (using `$request->old()`). Worry no more, this has been taken care of as well. The above code will automatically fill in the `email` field if `$session->old('email')` exists. Amazing.

### Models in the HTML builder

[](#models-in-the-html-builder)

The HTML builder can also generate elements based on a model:

```
{{ html()->modelForm($user)->open() }}

{{ html()->input('name') }}

{{ html()->closeModelForm() }}
```

The value of the `name` field will automatically be filled with the model's `name` property if available:

```

```

A "model" can be any object that implements `ArrayAccess` — anything from a complex Eloquent model to a plain array.

Postcardware
------------

[](#postcardware)

You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

All postcards are published [on our website](https://spatie.be/en/opensource/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-html
```

Next, you must install the service provider:

```
// config/app.php
'providers' => [
    ...
    Spatie\Html\HtmlServiceProvider::class,
];
```

And optionally register an alias for the facade.

```
// config/app.php
'aliases' => [
    ...
    'Html' => Spatie\Html\Facades\Html::class,
];
```

Usage
-----

[](#usage)

### Concepts

[](#concepts)

Elements—classes under the `Spatie\Html\Elements` namespace—are generally created via a `Spatie\Html\Html` builder instance.

```
html()->span()->text('Hello world!');
```

Element attributes and contents are modified via with fluent methods which return a new instance. This means element instances are immutable.

```
$icon = html()->span()->class('fa');

$icon->class('fa-eye'); // ''
$icon->class('fa-eye-slash'); // ''
```

Element classes don't have any knowledge of the outside world. Any coupling to other concepts, like requests and sessions, should happen in the builder class, not on the element classes.

By convention, we assume that builder methods will modify values to our advantage (like pulling old values from the session on a failed form request), and element methods will be deterministic.

```
// This will try to resolve an initial value, and fall back to 'hello@example.com'
$email = html()->email('email', 'hello@example.com');

// This will always have 'hello@example.com' as it's value
$email = html()->email('email')->value('hello@example.com');
```

Upgrading
---------

[](#upgrading)

### From v1 to v2

[](#from-v1-to-v2)

Version 2 was created because the typehints in version 1 was holding the package back in some cases (like multiple select which requires an array of values instead of a string which was assumed).

Luckily, bumping the version number in `composer.json` and running `composer update` should be non-breaking. Here are some caveats to look out for:

- The package now ships with a `html()` function by default, which returns an instance of the `Html` builder class. If you've defined your own method, you'll need to remove it.
- Various type hints have been removed throughout the package, if you've extended a class to override its methods, you'll need to update them accordingly (everything still behaves the same!)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

About Spatie
------------

[](#about-spatie)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 57% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~231 days

Total

70

Last Release

1177d ago

Major Versions

0.2.3 → 1.0.02017-03-31

1.5.0 → 2.0.02017-06-13

v1.x-dev → 2.22.12019-07-16

2.24.7 → 3.02020-11-13

PHP version history (4 changes)0.1.0PHP ^7.1

2.0.0PHP ^7.0

3.0PHP ^7.4

3.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dfd7abe6d76f60f1fe0b5d24abd419f4945bd41766823f9134bb877bb3f5a34?d=identicon)[Laraveldaily](/maintainers/Laraveldaily)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (171 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (53 commits)")[![mc0de](https://avatars.githubusercontent.com/u/8727992?v=4)](https://github.com/mc0de "mc0de (14 commits)")[![flyingluscas](https://avatars.githubusercontent.com/u/6232791?v=4)](https://github.com/flyingluscas "flyingluscas (10 commits)")[![rickselby](https://avatars.githubusercontent.com/u/1564517?v=4)](https://github.com/rickselby "rickselby (7 commits)")[![billmn](https://avatars.githubusercontent.com/u/779534?v=4)](https://github.com/billmn "billmn (5 commits)")[![fdrobnic](https://avatars.githubusercontent.com/u/35068993?v=4)](https://github.com/fdrobnic "fdrobnic (5 commits)")[![wesleyhf](https://avatars.githubusercontent.com/u/2936121?v=4)](https://github.com/wesleyhf "wesleyhf (3 commits)")[![sebastiaanluca](https://avatars.githubusercontent.com/u/711940?v=4)](https://github.com/sebastiaanluca "sebastiaanluca (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![andrewxtsang](https://avatars.githubusercontent.com/u/11076260?v=4)](https://github.com/andrewxtsang "andrewxtsang (2 commits)")[![arcanedev-maroc](https://avatars.githubusercontent.com/u/3282340?v=4)](https://github.com/arcanedev-maroc "arcanedev-maroc (2 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (2 commits)")[![aykutcan](https://avatars.githubusercontent.com/u/98998?v=4)](https://github.com/aykutcan "aykutcan (2 commits)")[![bmichotte](https://avatars.githubusercontent.com/u/235510?v=4)](https://github.com/bmichotte "bmichotte (2 commits)")[![frasermurraysco](https://avatars.githubusercontent.com/u/7722146?v=4)](https://github.com/frasermurraysco "frasermurraysco (2 commits)")[![paulredmond](https://avatars.githubusercontent.com/u/177773?v=4)](https://github.com/paulredmond "paulredmond (2 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![maldechavda](https://avatars.githubusercontent.com/u/4025859?v=4)](https://github.com/maldechavda "maldechavda (1 commits)")[![markvaneijk](https://avatars.githubusercontent.com/u/1925388?v=4)](https://github.com/markvaneijk "markvaneijk (1 commits)")

---

Tags

spatiehtml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laraveldaily-laravel-html/health.svg)

```
[![Health](https://phpackages.com/badges/laraveldaily-laravel-html/health.svg)](https://phpackages.com/packages/laraveldaily-laravel-html)
```

###  Alternatives

[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-feed

Generate rss feeds

9743.6M28](/packages/spatie-laravel-feed)[spatie/laravel-referer

Keep a visitor's original referer in session

532797.4k6](/packages/spatie-laravel-referer)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
