title: How do I compress HTML in laravel 5
body: <p>In Laravel 4.0, I use the code below to compress the HTML laravel response outputs to browser, however it doesn't work in laravel 5.</p>
  
  <pre><code>App::after(function($request, $response)
  {
      if($response instanceof Illuminate\Http\Response)
      {
          $buffer = $response-&gt;getContent();
          if(strpos($buffer,'&lt;pre&gt;') !== false)
          {
              $replace = array(
                  '/&lt;!--[^\[](.*?)[^\]]--&gt;/s' =&gt; '',
                  "/&lt;\?php/"                  =&gt; '&lt;?php ',
                  "/\r/"                      =&gt; '',
                  "/&gt;\n&lt;/"                    =&gt; '&gt;&lt;',
                  "/&gt;\s+\n&lt;/"                 =&gt; '&gt;&lt;',
                  "/&gt;\n\s+&lt;/"                 =&gt; '&gt;&lt;',
              );
          }
          else
          {
              $replace = array(
                  '/&lt;!--[^\[](.*?)[^\]]--&gt;/s' =&gt; '',
                  "/&lt;\?php/"                  =&gt; '&lt;?php ',
                  "/\n([\S])/"                =&gt; '$1',
                  "/\r/"                      =&gt; '',
                  "/\n/"                      =&gt; '',
                  "/\t/"                      =&gt; '',
                  "/ +/"                      =&gt; ' ',
              );
          }
          $buffer = preg_replace(array_keys($replace), array_values($replace), $buffer);
          $response-&gt;setContent($buffer);
      }
  });
  </code></pre>
  
  <p>Please how do i make this work in Laravel 5. </p>
  
  <p>OR</p>
  
  <p>Please provide a better way of compressing HTML in laravel 5 if any.
  Thanks in advance. </p>
  
  <p>NB: I don't wish to use any laravel package for compressing html, just need a simple code that does the work without killing performance.</p>