-
-
Save tadeubdev/7f3cc759e56e04b1f19f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
### --- Snip --- ### | |
App::after(function($request, $response) | |
{ | |
// HTML Minification | |
if(App::Environment() != 'local') | |
{ | |
if($response instanceof Illuminate\Http\Response) | |
{ | |
$output = $response->getOriginalContent(); | |
// Clean comments | |
$output = preg_replace('/<!--([^\[|(<!)].*)/', '', $output); | |
$output = preg_replace('/(?<!\S)\/\/\s*[^\r\n]*/', '', $output); | |
// Clean Whitespace | |
$output = preg_replace('/\s{2,}/', '', $output); | |
$output = preg_replace('/(\r?\n)/', '', $output); | |
$response->setContent($output); | |
} | |
} | |
}); | |
### --- Snip --- ### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LARAVEL 5
adicionar no arquivo Controler (Base)
public function __construct()
{
$this->middleware(function ($request, $next) {
echo "before filter";
$response = $next($request);
echo "after filter";
return $response;
});
}