PHPackages                             vrkansagara/lara-out-press - 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. vrkansagara/lara-out-press

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

vrkansagara/lara-out-press
==========================

This is simply compress your final out of Laravel Application and serve to the browser.

2.1.6(2w ago)6726.4k↑163.3%11BSD-3-ClausePHPPHP ^8.2|^8.3|^8.4CI passing

Since Apr 1Pushed 2w ago3 watchersCompare

[ Source](https://github.com/vrkansagara/LaraOutPress)[ Packagist](https://packagist.org/packages/vrkansagara/lara-out-press)[ Docs](https://vrkansagara.in)[ GitHub Sponsors](https://github.com/vrkansagara)[ Patreon](https://www.patreon.com/vrkansagara)[ RSS](/packages/vrkansagara-lara-out-press/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (6)Versions (23)Used By (0)

 [![LaraOutPress](Images/LaraOutPress.png?raw=true)](Images/LaraOutPress.png?raw=true)

LaraOutPress
============

[](#laraoutpress)

**Compress your Laravel application's HTML/JS output before it hits the wire — zero controller changes required.**

 [![Packagist](https://camo.githubusercontent.com/5cc0912952ab94ad6fc432f5a77df484c56291713bcb5f1210a2f48363e80c3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76726b616e7361676172612f6c6172612d6f75742d7072657373)](https://packagist.org/packages/vrkansagara/lara-out-press) [![Build](https://github.com/vrkansagara/LaraOutPress/actions/workflows/php.yml/badge.svg)](https://github.com/vrkansagara/LaraOutPress/actions/workflows/php.yml) [![PHP](https://camo.githubusercontent.com/313511725c3ae640a1d605fbb5f2075258999dc55a4c8569514083374812fdbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e32253230253743253230253545382e33253230253743253230253545382e342d373737626234)](https://camo.githubusercontent.com/313511725c3ae640a1d605fbb5f2075258999dc55a4c8569514083374812fdbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e32253230253743253230253545382e33253230253743253230253545382e342d373737626234) [![License](https://camo.githubusercontent.com/0aaf25175204cf9f5a9d2e1c0a64d59acb4fae66918c7224bf350bb0cadc1bf2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c7565)](https://camo.githubusercontent.com/0aaf25175204cf9f5a9d2e1c0a64d59acb4fae66918c7224bf350bb0cadc1bf2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c7565)

LaraOutPress is a single `after` middleware. It sits at the end of the pipeline, strips unnecessary whitespace and comments out of your rendered HTML response, does a light pass of inline JavaScript minification, and hands the browser a smaller payload — with zero changes to your controllers, views, or routes.

---

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

[](#installation)

```
composer require vrkansagara/lara-out-press
```

Laravel's package auto-discovery registers the service provider and facade for you. If your app has auto-discovery disabled, add the provider manually in `bootstrap/providers.php`(Laravel 11+) or `config/app.php` (Laravel ≤10):

```
Vrkansagara\LaraOutPress\ServiceProvider::class,
```

Publish the config file so you can override the defaults:

```
php artisan vendor:publish --provider="Vrkansagara\LaraOutPress\ServiceProvider"
```

This creates `config/laraoutpress.php` in your app.

> **"Unable to locate class or alias" when running `vendor:publish`?**That means Composer never registered the package in *this* app. Check, in order:
>
> 1. `composer show vrkansagara/lara-out-press` — confirms it's actually installed (not just listed in `composer.json`).
> 2. It's under `require`, not `require-dev`, if you run `composer install --no-dev` anywhere (CI, production deploys).
> 3. Re-run `composer dump-autoload` after installing — discovery is regenerated at that point.
> 4. Clear stale discovery caches: `php artisan package:discover` — or delete `bootstrap/cache/packages.php` and `bootstrap/cache/services.php` and let Laravel rebuild them.

---

Configuration
-------------

[](#configuration)

Every setting is controlled through environment variables, with `config/laraoutpress.php`as the published override point.

Env variableConfig keyDefaultPurpose`VRKANSAGARA_COMPRESS_ENABLED``enabled``false`Master on/off switch. Must be a real boolean.`VRKANSAGARA_COMPRESS_DEBUG``debug``false`Appends a before/after/percent-saved banner to every page.`VRKANSAGARA_COMPRESS_ENVIRONMENT``target_environment``''`Comma-separated list of environments compression runs in.*(config only)*`exclude_routes``['api/*']`Route patterns (as passed to `Request::is()`) that are never compressed.### Enable it

[](#enable-it)

```
VRKANSAGARA_COMPRESS_ENABLED=true
```

Only the literal boolean `true` enables the middleware. Anything else — an empty string, `"1"`, a stray typo — is treated as `false` on purpose, so a misconfigured value fails safe instead of silently compressing (or not compressing) unexpectedly.

### Choose which environment(s) it runs in

[](#choose-which-environments-it-runs-in)

```
# Single environment
VRKANSAGARA_COMPRESS_ENVIRONMENT=production

# Multiple environments
VRKANSAGARA_COMPRESS_ENVIRONMENT=production,staging,local
```

> **Don't reference `${APP_ENV}` in your `.env` file.** A line like `VRKANSAGARA_COMPRESS_ENVIRONMENT="${APP_ENV}"` looks natural (avoid repeating the value), but plain `.env` files are parsed by [`vlucas/phpdotenv`](https://github.com/vlucas/phpdotenv), which does **not** expand `${VAR}` references the way a shell or Docker Compose does. You'd get the literal 10-character string `${APP_ENV}` instead of `local` — and compression would silently never activate. Write the actual environment name.
>
> As a safety net, LaraOutPress falls back to the app's *current* environment whenever `target_environment` is left empty or still contains an unresolved `${...}` placeholder, so this mistake now fails safe rather than silently.

### See the impact on every page

[](#see-the-impact-on-every-page)

```
VRKANSAGARA_COMPRESS_DEBUG=true
```

Appends a fixed banner to the bottom of every compressed page showing the response size before and after compression, and the percentage saved. Turn this off in production — it's a development/staging aid, not a user-facing feature.

### Exclude routes

[](#exclude-routes)

Compression is skipped automatically for JSON responses (`$request->expectsJson()`) and for any route matching a pattern in `exclude_routes` (published in `config/laraoutpress.php`, matched via Laravel's `Request::is()`):

```
// config/laraoutpress.php
'exclude_routes' => [
    'api/*',
    'webhooks/*',
],
```

---

Which `.env` file actually applies?
-----------------------------------

[](#which-env-file-actually-applies)

Laravel only loads **one** `.env` file per request by default — the plain `.env` at your project root — regardless of how many environment-specific files (`.env.local`, `.env.production`, `.env.dusk.local`, …) sit next to it. Those extra files are conventions from other tools (Vite, Dusk, deployment scripts) and are **not** read by Laravel/`vlucas/phpdotenv` automatically unless your app explicitly opts in via `$app->loadEnvironmentFrom(...)` or the `--env` artisan flag.

In practice, that means:

- If you have both `.env` and `.env.production` and you deploy without changing how the app boots, **`.env` wins** — `.env.production` is inert dead weight.
- `APP_ENV` itself is read from `.env`, so it can't be used to *choose* which `.env`file loads unless something upstream (your deploy pipeline, `php artisan serve --env=`, a custom bootstrapper) sets `APP_ENV` **before** Laravel boots and points it at a different file.
- When in doubt, dump what Laravel actually resolved instead of guessing from the file list:

    ```
    php artisan tinker --execute="echo app()->environment();"
    ```

If your deployment relies on multiple `.env.*` files being auto-selected, that selection logic lives in your own `bootstrap/app.php` / deployment tooling, not in Laravel core or in this package — make sure `VRKANSAGARA_COMPRESS_*` variables are set in whichever file actually gets loaded for that environment.

---

What gets touched
-----------------

[](#what-gets-touched)

- HTML whitespace between tags is collapsed.
- HTML comments (``) are stripped.
- Inline `` content goes through a light JS-comment/whitespace minifier.
- JSON responses, excluded routes, and non-matching environments are always passed through untouched.

Development
-----------

[](#development)

```
composer install
composer run-script test      # PHPUnit
composer run-script cs-check  # PHP_CodeSniffer
```

CI runs the full suite across PHP 8.2, 8.3, and 8.4 on every push and pull request.

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

[](#contributing)

Issues and pull requests are very welcome — see [SECURITY.md](SECURITY.md) for how to report a vulnerability privately.

Made with ❤️ in India [![](Images/India.svg)](Images/India.svg)

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance96

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98.5% 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 ~179 days

Recently: every ~402 days

Total

18

Last Release

20d ago

Major Versions

1.1.5 → 2.0.02019-01-08

PHP version history (5 changes)1.0PHP &gt;=5.5

2.0.0PHP &gt;=7.0

2.1.0PHP &gt;=7.0|^8.0

2.1.5PHP &gt;=7.0|^8.0|^8.3|^8.4

2.1.6PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12006483?v=4)[Vallabh Kansagara](/maintainers/vrkansagara)[@vrkansagara](https://github.com/vrkansagara)

---

Top Contributors

[![vrkansagara](https://avatars.githubusercontent.com/u/12006483?v=4)](https://github.com/vrkansagara "vrkansagara (133 commits)")[![cp-vrkansagara](https://avatars.githubusercontent.com/u/56913689?v=4)](https://github.com/cp-vrkansagara "cp-vrkansagara (1 commits)")[![fridzema](https://avatars.githubusercontent.com/u/8180660?v=4)](https://github.com/fridzema "fridzema (1 commits)")

---

Tags

compresslaravellarvel-applicationmiddlewareminifylaravelcompress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vrkansagara-lara-out-press/health.svg)

```
[![Health](https://phpackages.com/badges/vrkansagara-lara-out-press/health.svg)](https://phpackages.com/packages/vrkansagara-lara-out-press)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20919.9k](/packages/stephenjude-filament-blog)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

12287.4k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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