PHPackages                             steffenbrand/html-compress-middleware - 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. steffenbrand/html-compress-middleware

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

steffenbrand/html-compress-middleware
=====================================

HTML Compress Middleware

v1.0.0(8y ago)69PHPPHP &gt;=7.1

Since Mar 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/steffenbrand/html-compress-middleware)[ Packagist](https://packagist.org/packages/steffenbrand/html-compress-middleware)[ Docs](https://github.com/steffenbrand/html-compress-middleware)[ RSS](/packages/steffenbrand-html-compress-middleware/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/da2c1138a3426b2cf07bec035ef17151e139eff300d03f6eaa3bb73950a8c938/68747470733a2f2f706f7365722e707567782e6f72672f7374656666656e6272616e642f68746d6c2d636f6d70726573732d6d6964646c65776172652f762f737461626c65)](https://packagist.org/packages/steffenbrand/html-compress-middleware)[![Total Downloads](https://camo.githubusercontent.com/4a85226b2b1598cfaf9623b41fc98e528553144f9193c48022d6179ab7742907/68747470733a2f2f706f7365722e707567782e6f72672f7374656666656e6272616e642f68746d6c2d636f6d70726573732d6d6964646c65776172652f646f776e6c6f616473)](https://packagist.org/packages/steffenbrand/html-compress-middleware)[![Build Status](https://camo.githubusercontent.com/0dd08cf6472d76a49cf53b262037116d835ddb3b8721762e3b6645e177cd3b03/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7374656666656e6272616e642f68746d6c2d636f6d70726573732d6d6964646c65776172652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/steffenbrand/html-compress-middleware/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/80cc29f16ee2aa514f98d149f8f38c8f1c1dd99b366d661b325ba2b8fad194b9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7374656666656e6272616e642f68746d6c2d636f6d70726573732d6d6964646c65776172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/steffenbrand/html-compress-middleware/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/137df851130995cf5d72872f454ffa929370f66f8b732af12a96f8470e88bb04/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7374656666656e6272616e642f68746d6c2d636f6d70726573732d6d6964646c65776172652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/steffenbrand/html-compress-middleware/?branch=master)

HTML Compress Middleware
========================

[](#html-compress-middleware)

PSR-15 compliant middleware to compress html responses.

- [HTML Compress Middleware on Packagist](https://packagist.org/packages/steffenbrand/html-compress-middleware)
- [HTML Compress Middleware on GitHub](https://github.com/steffenbrand/html-compress-middleware)

[![Concept](https://github.com/steffenbrand/html-compress-middleware/raw/master/concept.jpg?raw=true)](https://github.com/steffenbrand/html-compress-middleware/blob/master/concept.jpg?raw=true)

How to install
--------------

[](#how-to-install)

```
composer require steffenbrand/html-compress-middleware

```

How to use with Zend Expressive 3
---------------------------------

[](#how-to-use-with-zend-expressive-3)

Add the middleware to your `config/pipeline.php`

```
/**
 * Setup middleware pipeline:
 */
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
    // The error handler should be the first (most outer) middleware to catch
    // all Exceptions.
    $app->pipe(ErrorHandler::class);
    $app->pipe(HtmlCompressMiddleware::class);
    ...
 }
```

Add the middleware to your `config/autoload/dependencies.global.php`
Or use it as a [routed middleware](https://zendframework.github.io/zend-expressive/v3/getting-started/features/#flow-overview), if you don't want the middleware to be invoked on certain routes.

```
return [
    // Provides application-wide services.
    // We recommend using fully-qualified class names whenever possible as
    // service names.
    'dependencies' => [
        ...
        'factories'  => [
            // Fully\Qualified\ClassName::class => Fully\Qualified\FactoryName::class,
            \SteffenBrand\HtmlCompressMiddleware\HtmlCompressMiddleware::class => \SteffenBrand\HtmlCompressMiddleware\HtmlCompressMiddlewareFactory::class,
        ],
    ],
];
```

### Enable compression

[](#enable-compression)

To enable compression disable the development mode.
HTML compression is only meant for production.

```
composer development-disable

```

### Disable compression

[](#disable-compression)

To disable compression enable the development mode.
HTML compression will not run in development mode.

```
composer development-enable

```

Or provide your own development-mode settings by editing the file `config/autoload/development.local.php.dist`

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3019d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c0012c84bdbe5a801bef48e509ea28f5aa0359dcba13286ff6065a298f21c49?d=identicon)[steffenbrand](/maintainers/steffenbrand)

---

Top Contributors

[![steffenbrand](https://avatars.githubusercontent.com/u/5013806?v=4)](https://github.com/steffenbrand "steffenbrand (29 commits)")

---

Tags

html-compressingmiddlewarepsr-11psr-15psr-7zend-expressive3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/steffenbrand-html-compress-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/steffenbrand-html-compress-middleware/health.svg)](https://phpackages.com/packages/steffenbrand-html-compress-middleware)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.5k937.5k69](/packages/mcp-sdk)

PHPackages © 2026

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