PHPackages                             caujasutom/laravel-optimizer - 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. caujasutom/laravel-optimizer

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

caujasutom/laravel-optimizer
============================

A lightweight Laravel package to optimize performance by minifying HTML, caching, and more.

4245[1 issues](https://github.com/caujasutom/laravel-optimizer/issues)PHP

Since Sep 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/caujasutom/laravel-optimizer)[ Packagist](https://packagist.org/packages/caujasutom/laravel-optimizer)[ RSS](/packages/caujasutom-laravel-optimizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Optimizer Package
=========================

[](#laravel-optimizer-package)

The Laravel Optimizer package is a collection of middlewares and helpers designed to optimize and improve the performance of your Laravel applications. It includes HTML minification, static HTML caching, and Gzip compression.

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Configuration](#configuration)
3. [Middlewares](#middlewares)
    1. [HTML Minify Middleware](#html-minify-middleware)
    2. [Static HTML Cache Middleware](#static-html-cache-middleware)
    3. [Gzip Compression Middleware](#gzip-compression-middleware)
4. [Helpers](#helpers)
5. [Examples](#examples)

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

[](#installation)

To install the Laravel Optimizer package, run the following command in your project's root directory:

```
composer require caujasutom/laravel-optimizer
```

After installing the package, publish the configuration file by running the following command:

```
php artisan vendor:publish --provider="Caujasutom\LaravelOptimizer\LaravelOptimizerServiceProvider"
```

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

[](#configuration)

The configuration file `config/laravel_optimizer.php` contains the default settings for the package. You can modify these settings to suit your needs.

```
```

 env('LARAVEL_OPTIMIZER_STATIC_CACHE_TTL', 60),
// Path for storing cache files.
'cache_path' => env('LARAVEL_OPTIMIZER_CACHE_PATH', 'static_cache/'),

// Compression level for gzip (0-9).
'compression_level' => env('LARAVEL_OPTIMIZER_COMPRESSION_LEVEL', 9),

// Gzip compression settings
'gzip_compression' => [
    'level' => env('LARAVEL_OPTIMIZER_GZIP_COMPRESSION_LEVEL', 9), // Default compression level for Gzip.
],

// Minification settings
'minification' => [
    'enabled' => env('LARAVEL_OPTIMIZER_MINIFICATION_ENABLED', true),
    'patterns' => [
        '/>\s+/s',
        '/\s+\s+',
        'delete($url)`

[](#laraveloptimizercache-deleteurl)

Deletes the cached HTML content for the given URL.

```
LaravelOptimizer::cache()->delete($url);
```

Parameters:

  Parameter Type Description   `$url` string The URL for which to delete the cached HTML content. Examples
--------

[](#examples)

```
```
namespace App\Http\Controllers;
use Caujasutom\LaravelOptimizer\Facades\LaravelOptimizer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
class ArticlesController extends Controller
{
/**
* Display a listing of articles.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// Check if cached HTML content exists for this URL
$cachedContent = LaravelOptimizer::cache()->retrieve(request()->url());
if ($cachedContent) {
// If cached content exists, return it
return response($cachedContent);
} else {
// If cached content doesn't exist, generate and cache new content
$articles = Post::all(); // Fetch articles from the database or any other source
        // Render the articles view
        $htmlContent = View::make('articles.index', ['articles' => $articles])->render();

        // Cache the generated HTML content for this URL
        LaravelOptimizer::cache()->store(request()->url(), $htmlContent);

        return response($htmlContent);
    }
}

```}

```

In this example, we have an `ArticlesController` with an `index` function. This function is responsible for displaying a listing of articles.

Here's the breakdown of the function:

1. First, it checks if there is cached HTML content available for the current URL using the `LaravelOptimizer::cache()->retrieve(request()->url())` method.
2. If cached content exists, it returns the cached HTML content as the response.
3. If cached content doesn't exist, it fetches the articles from the database or any other source.
4. It then renders the `articles.index` view with the fetched articles using `View::make()` and `render()` methods.
5. The generated HTML content is stored in the variable `$htmlContent`.
6. The generated HTML content is cached using `LaravelOptimizer::cache()->store(request()->url(), $htmlContent)` method.
7. Finally, it returns the generated HTML content as the response.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance24

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1d96f557590f3510e54b200e1632305e13fb3159e1644a3a8083e626d0e906d?d=identicon)[caujasutom](/maintainers/caujasutom)

---

Top Contributors

[![caujasutom](https://avatars.githubusercontent.com/u/85121888?v=4)](https://github.com/caujasutom "caujasutom (18 commits)")

---

Tags

laravellaravel-packageoptimization

### Embed Badge

![Health badge](/badges/caujasutom-laravel-optimizer/health.svg)

```
[![Health](https://phpackages.com/badges/caujasutom-laravel-optimizer/health.svg)](https://phpackages.com/packages/caujasutom-laravel-optimizer)
```

###  Alternatives

[klepak/nova-dynamic-page-title

Dynamically updates Laravel Nova page title based on data from Vue router.

11154.8k](/packages/klepak-nova-dynamic-page-title)

PHPackages © 2026

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