PHPackages                             stolz/laravel-html-tidy - 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. [Search &amp; Filtering](/categories/search)
4. /
5. stolz/laravel-html-tidy

ActiveLibrary[Search &amp; Filtering](/categories/search)

stolz/laravel-html-tidy
=======================

HTML Tidy middleware for Laravel

0.1.4(6y ago)268.7k6[2 issues](https://github.com/Stolz/laravel-html-tidy/issues)MITPHPPHP &gt;=5.4

Since Aug 5Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Stolz/laravel-html-tidy)[ Packagist](https://packagist.org/packages/stolz/laravel-html-tidy)[ RSS](/packages/stolz-laravel-html-tidy/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

Laravel HTML Tidy
=================

[](#laravel-html-tidy)

tl;dr
-----

[](#tldr)

[Laravel-html-tidy](https://github.com/Stolz/laravel-html-tidy) is a [Laravel middleware](http://laravel.com/docs/master/middleware) that parses Laravel's *Response* objects in order to detect and fix markup problems as well as to improve the layout and indent style of the resulting markup.

How it works
------------

[](#how-it-works)

When editing HTML it's easy to make mistakes. Did you ever forget to close a `` tag that made a mess of all your layout and then you went crazy trying to figure out what/where the problem was?. Wouldn't it be nice if there was a simple way to detect and fix these mistakes automatically and at the same time tidy up sloppy editing into nicely layed out markup? Well that is what [W3C HTML Tidy](http://www.w3.org/People/Raggett/tidy/) utility is for!. HTML Tidy is available as an official [PHP extension](http://www.php.net/manual/en/book.tidy.php) and this package makes using it with Laravel a breeze.

Once the middleware is enabled every time there is a problem with your HTML code you will see an error messages on your screen. Tidy will try its best to fix the problem for you. Also, if you take a look of the final HTML code sent to the browser you will get a pleasant surprise.

**Note:** HTML Tidy is fast but parsing output always adds a small overhead so consider using the middleware only in development environments.

Requirements
------------

[](#requirements)

- PHP compiled with HTML Tidy support and [Tidy](http://php.net/manual/en/book.tidy.php) extension enabled in php.ini.
- Laravel framework.

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

[](#installation)

Install via composer

```
composer require stolz/laravel-html-tidy --dev

```

If you are using an old version of Laravel without the package discovery feature (or if you have disabled it), then you have to manually edit `config/app.php` file and add the service provider to the `providers` array:

```
'providers' => [
	...
	'Stolz\HtmlTidy\ServiceProvider',
],

```

The default settings can validate both (x)HTML 4 and HTML 5 markups. If you want to customize the settings create the file `config/tidy.php` by running

```
php artisan vendor:publish --provider='Stolz\HtmlTidy\ServiceProvider'

```

Usage
-----

[](#usage)

If you want the middleware to be run only on specific routes, add the class in the `$routeMiddleware` property of your `app/Http/Kernel.php` file, with your desired short-hand key.

```
protected $routeMiddleware = [
	...
	'tidy' => 'Stolz\HtmlTidy\Middleware',
];

```

Now you can use it in your `routes.php` file

```
Route::get('some/url', function () {...})->middleware('tidy');

```

Conversely if you want the middleware to be run on every HTTP request to your application, add the class in the `$middleware` property of your `app/Http/Kernel.php` file.

```
protected $middleware = [
	...
	'Stolz\HtmlTidy\Middleware',
];

```

Laravel 4
---------

[](#laravel-4)

If you are still using Laravel 4 instead of loading `Stolz\HtmlTidy\ServiceProvider` use `Stolz\HtmlTidy\LegacyServiceProvider` and then in your `routes.php` file use something like this

```
// Register filter
Route::filter('tidy', function($route, $request, $response) {
	return app('stolz.tidy')->handle($request, $response);
});

// Use as an 'after' filter
Route::get('/', ['after' => 'tidy', function() {
	return View::make('home');
}]);

```

License
-------

[](#license)

MIT License © [Stolz](https://github.com/Stolz)

Read the provided `LICENSE` file for details.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~411 days

Recently: every ~467 days

Total

6

Last Release

2244d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.3.0

0.1.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/0471c7d87aae4a16a5cb6a04f44963ae1756b29bfa27c4fe7d2fdf479bdbbf6e?d=identicon)[Stolz](/maintainers/Stolz)

---

Top Contributors

[![Stolz](https://avatars.githubusercontent.com/u/291060?v=4)](https://github.com/Stolz "Stolz (60 commits)")

---

Tags

middlewarelaravelhtmlPurifierHTML5filterhtmlpurifiermarkupHTMLtidytidyindentbeautifier

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[xemlock/htmlpurifier-html5

HTML5 support for HTML Purifier

1052.9M11](/packages/xemlock-htmlpurifier-html5)[kyslik/laravel-filterable

Using URL query strings to filter Eloquent queries.

11539.0k](/packages/kyslik-laravel-filterable)[hashemi/queryfilter

A simple &amp; dynamic package for your eloquent query in laravel. It will help you to write query logic individual for each parameter.

391.1k](/packages/hashemi-queryfilter)

PHPackages © 2026

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