Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function __invoke(Request $request, Response $response, callable $next)
 {
     if ($request->getAttribute('profiler')) {
         //Already handled at top level
         return $next($request, $response);
     }
     $outerHandler = $this->debugger->shareHandler($this->handler = new SharedHandler());
     try {
         $response = $next($request->withAttribute('profiler', $this->started));
         $elapsed = microtime(true) - $this->started;
     } finally {
         //Restoring original debug handler
         $this->debugger->shareHandler($outerHandler);
     }
     //Mounting profiler panel
     return $this->mountPanel($request, $response, $this->started, $elapsed);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function start(ConsoleHandler $handler = null)
 {
     //Some console commands utilizes benchmarking, let's help them
     $this->container->bind(BenchmarkerInterface::class, Debugger::class);
     $output = new ConsoleOutput();
     $this->debugger->shareHandler($this->consoleHandler($output));
     $scope = $this->container->replace(LogsInterface::class, $this->debugger);
     try {
         $this->application()->run(null, $output);
     } finally {
         $this->container->restore($scope);
     }
 }