vendredi 12 octobre 2018

how can I minify the code with middleware in laravel

I want to minify my Code so I have This fucntion

 function minifyHTML($htmlString)
{
    $replace = [
        '<!--(.*?)-->' => '', //remove comments
        "/<\?php/" => '<?php ',
        "/\n([\S])/" => '$1',
        "/\r/" => '', // remove carriage return
        "/\n/" => '', // remove new lines
        "/\t/" => '', // remove tab
        "/\s+/" => ' ', // remove spaces
    ];
    return preg_replace(array_keys($this->replace), array_values($this->replace), $htmlString);
}

and I have This Middleware

 public function handle($request, Closure $next)
{
    return $next($request);
}

I want cerate This Route :

Route::get('/', function () {
return view('welcome');

})->middleware('minifier');

and get the minifire code I have to create with only This way Because my teacher want Please help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire