PHP code example of puklipo / laravel-vapor-gzip

1. Go to this page and download the library: Download puklipo/laravel-vapor-gzip 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/ */

    

puklipo / laravel-vapor-gzip example snippets


use Puklipo\Vapor\Middleware\GzipResponse::class;

->withMiddleware(function (Middleware $middleware) {
     $middleware->append(GzipResponse::class);
})

use Illuminate\Http\Request;
use Puklipo\Vapor\Middleware\GzipResponse;

public function boot(): void
{
    GzipResponse::encodeWhen(function (Request $request, mixed $response): bool {
        return in_array('gzip', $request->getEncodings())
            && $request->method() === 'GET'
            && function_exists('gzencode')
            && ! $response->headers->contains('Content-Encoding', 'gzip')
            && ! $response instanceof BinaryFileResponse;
    });
}

namespace App\Http\Middleware;