public function registerProfilerToOutput()
	{
		$app = $this->app;
		$sessionHash = static::SESSION_HASH;

		$app['router']->after(function($request, $response) use ($app, $sessionHash)
		{
			$profiler = $app['profiler'];
			$session = $app['session'];

			if($session->has($sessionHash))
			{
				$profiler->enable($session->get($sessionHash));
			}

			// Do not display profiler on ajax requests or non-HTML responses.
			$isHTML = \Str::startsWith($response->headers->get('Content-Type'), 'text/html');

			if( ! $profiler->isEnabled() or $request->ajax() or ! $isHTML)
			{
				return;
			}

			$responseContent = $response->getContent();

			// Don't do anything if the response content is not a string.
			if(is_string($responseContent))
			{
				$profiler = $profiler->render();

				// If we can find a closing HTML tag in the response, let's add the
				// profiler content inside it.
				if(($pos = strrpos($responseContent, '</html>')) !== false)
				{
					$responseContent = substr($responseContent, 0, $pos).$profiler.substr($responseContent, $pos);
				}

				// If we cannot find a closing HTML tag, we'll just append the profiler
				// at the very end of the response's content.
				else
				{
					$responseContent .= $profiler;
				}

				$response->setContent($responseContent);
			}
		});
	}
public function registerProfilerToOutput()
	{
		$app = $this->app;
		$sessionHash = static::SESSION_HASH;

		$app['router']->after(function($request, $response) use ($app, $sessionHash)
		{
			$profiler = $app['profiler'];
			$session = $app['session'];

			if($session->has($sessionHash))
			{
				$profiler->enable($session->get($sessionHash));
			}

			// Do not display profiler on ajax requests or non-HTML responses.
			$isHTML = \Str::startsWith($response->headers->get('Content-Type'), 'text/html');

			if( ! $profiler->isEnabled() or $request->ajax() or ! $isHTML)
			{
				return;
			}

			$responseContent = $response->getContent();

			// Don't do anything if the response content is not a string.
			if(is_string($responseContent))
			{
				$profiler = $profiler->render();

				// If we can find a closing HTML tag in the response, let's add the
				// profiler content inside it.
				if(($pos = strrpos($responseContent, '</html>')) !== false)
				{
					$responseContent = substr($responseContent, 0, $pos).$profiler.substr($responseContent, $pos);
				}

				// If we cannot find a closing HTML tag, we'll just append the profiler
				// at the very end of the response's content.
				else
				{
					$responseContent .= $profiler;
				}

				$response->setContent($responseContent);
			}
		});
	}
public function registerProfilerToOutput ( ) { $ app = $ this -> app ; $ sessionHash = static :: SESSION_HASH ; $ app [ 'router' ] -> after ( function ( $ request , $ response ) use ( $ app , $ sessionHash ) { $ profiler = $ app [ 'profiler' ] ; $ session = $ app [ 'session' ] ; if ( $ session -> has ( $ sessionHash ) ) { $ profiler -> enable ( $ session -> get ( $ sessionHash ) ) ; } // Do not display profiler on ajax requests or non-HTML responses. $ isHTML = \ Str :: startsWith ( $ response -> headers -> get ( 'Content-Type' ) , 'text/html' ) ; if ( ! $ profiler -> isEnabled ( ) or $ request -> ajax ( ) or ! $ isHTML ) { return ; } $ responseContent = $ response -> getContent ( ) ; // Don't do anything if the response content is not a string. if ( is_string ( $ responseContent ) ) { $ profiler = $ profiler -> render ( ) ; // If we can find a closing HTML tag in the response, let's add the // profiler content inside it. if ( ( $ pos = strrpos ( $ responseContent , '</html>' ) ) !== false ) { $ responseContent = substr ( $ responseContent , 0 , $ pos ) . $ profiler . substr ( $ responseContent , $ pos ) ; } // If we cannot find a closing HTML tag, we'll just append the profiler // at the very end of the response's content. else { $ responseContent .= $ profiler ; } $ response -> setContent ( $ responseContent ) ; } } ) ; }
Register an after filter to automatically display the profiler.

@return void
Register an after filter to automatically display the profiler .