PHPackages                             open-southeners/laravel-response-compression - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. open-southeners/laravel-response-compression

ActiveLibrary[HTTP &amp; Networking](/categories/http)

open-southeners/laravel-response-compression
============================================

Add server-side response compression with a range of different algorithms (Gzip, brotli, deflate...)

3.3.0(2mo ago)15159.0k↑12.9%2MITPHPPHP ^8.2CI failing

Since Jul 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/open-southeners/laravel-response-compression)[ Packagist](https://packagist.org/packages/open-southeners/laravel-response-compression)[ RSS](/packages/open-southeners-laravel-response-compression/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (12)Versions (13)Used By (0)

Laravel Response Compression [![required php version](https://camo.githubusercontent.com/48b49359cd4b1710943e63d4812142a6a8148983bf5ea90a6c73413a4da8166b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6f70656e2d736f757468656e6572732f6c61726176656c2d726573706f6e73652d636f6d7072657373696f6e)](https://www.php.net/supported-versions.php) [![codecov](https://camo.githubusercontent.com/5f8f38d27db0c55d5754f4f366d45e4e908831f2d53b4420c02ae154792c5973/68747470733a2f2f636f6465636f762e696f2f67682f6f70656e2d736f757468656e6572732f6c61726176656c2d726573706f6e73652d636f6d7072657373696f6e2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d51333141595858474f41)](https://codecov.io/gh/open-southeners/laravel-response-compression) [![Edit on VSCode online](https://camo.githubusercontent.com/1e825ede949540f53ec4dce8dc8ad93376081856a01b7e3ce2f24f41c9133405/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7673636f64652d656469742532306f6e6c696e652d626c75653f6c6f676f3d76697375616c73747564696f636f6465)](https://vscode.dev/github/open-southeners/laravel-response-compression)
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#laravel-response-compression---)

Add server-side response compression to Laravel with a range of different algorithms (Gzip, brotli, deflate...)

Why use this package?
---------------------

[](#why-use-this-package)

The reason why is because AWS **hard limit its API Gateway** service to 10MB (at the date of writing this), and by hard we mean that there's no way you can increase this limitation.

**Note: Thought CloudFlare is a good solution for the end user, it doesn't solve this issue as CloudFlare does this between the server and the client, so the response already passed through AWS (API Gateway).**

Read more here:

Or on our blog article:

Getting started
---------------

[](#getting-started)

```
composer require open-southeners/laravel-response-compression
```

Then publish the configuration file defaults into your application's config folder:

```
php artisan vendor:publish --tag=response-compression
```

Then add the following to you `app/Http/Kernel.php` as a global middleware:

**Note: Remember this is different in older versions of Laravel, Laravel 9 should look like the following.**

```
/**
 * The application's global HTTP middleware stack.
 *
 * These middleware are run during every request to your application.
 *
 * @var array
 */
protected $middleware = [
    // ...
    \OpenSoutheners\LaravelResponseCompression\ResponseCompression::class,
];
```

### Configuration

[](#configuration)

If you already have this `config/response-compression.php` file, you can skip this step, otherwise please use the following artisan command first:

```
php artisan vendor:publish --tag=response-compression
```

**Note: As for smaller responses this threshold will prevent to compress the response if it doesn't reach an specific number of bytes. We encourage you to configure this and not leave it as ±0 bytes otherwise response will be always compressed.**

This configuration is **defaulted to 10000 bytes**, you may customise this as your application demands.

### Setting up Brotli and/or ZStandard extensions in Vapor

[](#setting-up-brotli-andor-zstandard-extensions-in-vapor)

First of all, **this will require you to use Docker containers on your Vapor environments** if you're not familiar with them, you can still use this extension as **it uses the first client requested algorithm available at server side**.

👉 [Read more about using containers in Vapor here](https://docs.vapor.build/projects/environments#docker-runtimes)

#### Brotli

[](#brotli)

Anyway, in case you want to proceed, add this to your environment Dockerfile(s), **please use comments as references only**:

```
# FROM laravelphp/vapor:php84

RUN apk add --no-cache brotli

# COPY . /var/task
```

And ensure your project depends on [vdechenaux/brotli](https://github.com/vdechenaux/brotli-php).

### Alternative Brotli setup

[](#alternative-brotli-setup)

Another alternative is to use:

```
pecl install brotli
```

```
# FROM laravelphp/vapor:php84

RUN pecl install brotli \
    && docker-php-ext-enable brotli \

# COPY . /var/task
```

#### ZStandard

[](#zstandard)

Using

```
pecl install zstd
```

```
# FROM laravelphp/vapor:php84

RUN pecl install zstd  \
    && docker-php-ext-enable zstd \

# COPY . /var/task
```

#### Lz4

[](#lz4)

Using

**Note: Only Debian or RHEL packages here, Vapor uses Alpine as base images so no luck here...**

```
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php-lz4
```

Credits
-------

[](#credits)

- To [@jryd\_13](https://twitter.com/@jryd_13) for writing [the article](https://bannister.me/blog/gzip-compression-on-laravel-vapor/) that gave me this idea
- To [@kjdev](https://github.com/kjdev) for supporting PHP with all his amazing extensions used here for different compression algorithms

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance86

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% 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 ~123 days

Recently: every ~98 days

Total

12

Last Release

83d ago

Major Versions

1.0.0 → 2.0.02022-08-25

2.x-dev → 3.0.02025-03-05

PHP version history (4 changes)1.0.0PHP ^7.2|^8.0|^8.1

2.0.1PHP ^7.2|^8.0|^8.1|^8.2

2.1.0PHP ^7.2 || ^8.0

3.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2331052?v=4)[Ruben Robles](/maintainers/d8vjork)[@d8vjork](https://github.com/d8vjork)

---

Top Contributors

[![d8vjork](https://avatars.githubusercontent.com/u/2331052?v=4)](https://github.com/d8vjork "d8vjork (72 commits)")[![matthewnessworthy](https://avatars.githubusercontent.com/u/5653887?v=4)](https://github.com/matthewnessworthy "matthewnessworthy (1 commits)")[![TheoGibbons](https://avatars.githubusercontent.com/u/1817181?v=4)](https://github.com/TheoGibbons "TheoGibbons (1 commits)")

---

Tags

laravel-packagelaravel-vaporphp8response-compressionlaravelvaporopen-southenersresponse-compressionlaravel-vaporgzip-compressiondeflate-compressionbrotli-compressionztsd-compressionlz4-compression

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/open-southeners-laravel-response-compression/health.svg)

```
[![Health](https://phpackages.com/badges/open-southeners-laravel-response-compression/health.svg)](https://phpackages.com/packages/open-southeners-laravel-response-compression)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.3k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

2038.9k](/packages/onlime-laravel-http-client-global-logger)

PHPackages © 2026

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