Download the PHP package akankov/laravel-compress-html without Composer
On this page you can find all versions of the php package akankov/laravel-compress-html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-compress-html
laravel-compress-html
Laravel integration for akankov/html-min — adds a Blade @htmlmin block directive, an opt-in HTML response middleware, and a publishable config-driven service provider.
Requirements
- PHP
8.3.* || 8.4.* || 8.5.* - Laravel 12.x or 13.x
akankov/html-min^2.9
Install
The service provider is registered automatically via Laravel's package auto-discovery (extra.laravel.providers in composer.json); no manual config/app.php edit is needed.
Optionally publish the config file to tune the 29 minifier toggles:
This drops config/htmlmin.php into your application — every key defaults to the engine's default, so you only need to edit the ones you want to flip.
Blade directive
The block captures rendered output, then minifies it. Variables interpolated via {{ $expr }} are escaped by Blade before the buffer reaches the minifier, so it's safe to interpolate user data inside.
Response middleware
Opt-in: the service provider does not push the middleware onto the global stack — register it explicitly where you want it.
Globally, in bootstrap/app.php (Laravel 12+):
Or per-route / per-group:
The middleware only touches Illuminate\Http\Response instances whose Content-Type first segment is text/html. JSON, streamed, and binary responses pass through unchanged.
What "pass through" covers, precisely:
- Streamed responses (
StreamedResponse,BinaryFileResponse) are never buffered or minified — anything that is not a plainIlluminate\Http\Responseis returned as-is. - Partial content (
206responses to range requests) is skipped by the same mechanism in practice — range responses are produced as binary-file or streamed responses; minifying a byte range of HTML would corrupt it. - ESI/SSI fragments assembled by a proxy are minified per-fragment only if the proxy requests them as ordinary routes through this middleware — in that case each fragment is valid standalone HTML and minifies safely.
Configuration
Every key in config/htmlmin.php is a snake_case mirror of a property on Akankov\HtmlMin\Config\MinifierOptions. The provider converts them with Str::camel() when constructing the options object, so:
See the published config file for the full list of 29 keys with their defaults.
Artisan command
html-min:check minifies a file in memory and reports the byte savings — a CI/dev smoke-check for "did this template change inflate the page?" without writing anything to disk:
It exits 0 on success and 1 if the file cannot be read.
Versioning
This package follows Semantic Versioning. From 1.0.0 onward the public surface — the @htmlmin directive, the MinifyHtmlResponseMiddleware, the html-min:check command, the published config/htmlmin.php keys, and the service-provider bindings — is stable; breaking changes are reserved for a new major version. The underlying engine is tracked via a caret constraint (akankov/html-min: ^2.9), so it picks up engine minor/patch releases automatically.
Tests
The suite holds 100% line coverage, enforced in CI.
License
MIT
All versions of laravel-compress-html with dependencies
akankov/html-min Version ^2.9
illuminate/contracts Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
illuminate/view Version ^12.0 || ^13.0