PHP code example of akankov / laravel-compress-html

1. Go to this page and download the library: Download akankov/laravel-compress-html library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akankov / laravel-compress-html example snippets


use Akankov\LaravelCompressHtml\Http\MinifyHtmlResponseMiddleware;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    // …
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->append(MinifyHtmlResponseMiddleware::class);
    })
    // …
    ->create();

use Akankov\LaravelCompressHtml\Http\MinifyHtmlResponseMiddleware;

Route::middleware(MinifyHtmlResponseMiddleware::class)
    ->group(function (): void {
        // routes whose responses should be minified
    });

'remove_comments'    => true,    // → MinifierOptions::$removeComments
'sum_up_whitespace'  => true,    // → MinifierOptions::$sumUpWhitespace
'optimize_attributes' => true,   // → MinifierOptions::$optimizeAttributes
sh
php artisan vendor:publish --tag=htmlmin-config