PHPackages                             heliip/laravel-encrypted-responses - 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. [API Development](/categories/api)
4. /
5. heliip/laravel-encrypted-responses

ActiveLibrary[API Development](/categories/api)

heliip/laravel-encrypted-responses
==================================

Laravel middleware to encrypt API responses using Laravel Crypt with optional compressed payloads.

v1.0.0(1mo ago)016↓80%MITPHPPHP ^8.3CI passing

Since Jun 10Pushed 1mo agoCompare

[ Source](https://github.com/cponce-framepexls/laravel-encrypted-responses)[ Packagist](https://packagist.org/packages/heliip/laravel-encrypted-responses)[ Docs](https://github.com/heliip/laravel-encrypted-responses)[ RSS](/packages/heliip-laravel-encrypted-responses/feed)WikiDiscussions produccion Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Heliip Laravel Encrypted Responses
==================================

[](#heliip-laravel-encrypted-responses)

Laravel package for encrypting API responses with Laravel's `Crypt` service.

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

[](#requirements)

- PHP 8.3 or higher
- Laravel 13
- PHP extensions: `json`, `zlib`

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

[](#installation)

```
composer require heliip/laravel-encrypted-responses
php artisan vendor:publish --tag=encrypted-responses-config
```

Usage
-----

[](#usage)

Enable automatic registration for the `api` middleware group:

```
ENCRYPT_RESPONSES_AUTO_REGISTER=true
```

Or register the middleware manually in `bootstrap/app.php`:

```
use Heliip\LaravelEncryptedResponses\Http\Middleware\EncryptResponse;
use Illuminate\Foundation\Configuration\Middleware;

->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        EncryptResponse::class,
    ]);
})
```

For specific routes, use the middleware alias:

```
Route::middleware('encrypt.responses')->get('/profile', ProfileController::class);
```

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

[](#configuration)

The configuration file is published to `config/encrypted-responses.php`.

Common environment variables:

```
ENCRYPT_RESPONSES_ENABLED=true
ENCRYPT_RESPONSES_AUTO_REGISTER=false
ENCRYPT_RESPONSES_JSON_ENCODED_COMPRESSED_PAYLOAD=true
ENCRYPT_RESPONSES_COMPRESS=true
ENCRYPT_RESPONSES_COMPRESSION_LEVEL=9
ENCRYPT_RESPONSES_OUTPUT=raw
ENCRYPT_RESPONSES_CONTENT_TYPE=text/plain
```

`ENCRYPT_RESPONSES_OUTPUT=raw` returns the encrypted string as the response body.

`ENCRYPT_RESPONSES_OUTPUT=json` returns:

```
{"payload":"encrypted-value"}
```

Payload Format
--------------

[](#payload-format)

With `ENCRYPT_RESPONSES_JSON_ENCODED_COMPRESSED_PAYLOAD=true`, payloads are encoded as:

```
Crypt::encryptString(json_encode(base64_encode(gzcompress(json_encode($data), 9))))
```

Exclusions
----------

[](#exclusions)

The middleware skips:

- Binary file responses
- Streamed responses
- Empty responses such as `204` and `304`
- Excluded paths and route names
- Excluded content types such as images, video, PDF, and ZIP

To skip encryption for a single request:

```
X-Skip-Response-Encryption: 1
```

Manual Encryption
-----------------

[](#manual-encryption)

```
use Heliip\LaravelEncryptedResponses\Facades\EncryptedResponse;

$encrypted = EncryptedResponse::encrypt(['ok' => true]);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/135511397?v=4)[cponce-framepexls](/maintainers/cponce-framepexls)[@cponce-framepexls](https://github.com/cponce-framepexls)

---

Top Contributors

[![cponce-framepexls](https://avatars.githubusercontent.com/u/135511397?v=4)](https://github.com/cponce-framepexls "cponce-framepexls (2 commits)")

---

Tags

responsemiddlewareapilaravelencryption

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/heliip-laravel-encrypted-responses/health.svg)

```
[![Health](https://phpackages.com/badges/heliip-laravel-encrypted-responses/health.svg)](https://phpackages.com/packages/heliip-laravel-encrypted-responses)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)[illuminate/routing

The Illuminate Routing package.

1419.2M3.2k](/packages/illuminate-routing)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)

PHPackages © 2026

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