Created
June 22, 2012 11:28
-
-
Save antoniofrignani/2972206 to your computer and use it in GitHub Desktop.
[LARAVEL] Compress filter for Laravel
This file contains hidden or 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 | |
/* | |
|-------------------------------------------------------------------------- | |
| Compress output before sending it to the browser | |
|-------------------------------------------------------------------------- | |
| | |
| Removes all tabs and line breaks from the content before sending it to | |
| the browser. | |
| | |
| @example: | |
| Route::group(array('after' => 'compress'), function() | |
| { | |
| Route::controller('home'); | |
| }); | |
| | |
*/ | |
Route::filter('compress', function( $response = null ) | |
{ | |
// Ensure we have a response, just in case someone sets the compress filter to run | |
// 'before' the request is sent to Laravel. | |
if ( $response ) { | |
$response->content = str_replace( array("\n","\t") , '' , $response->content ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment