/** * instance. * * @method instance * * @param array$config * * @return static */ public static function instance($config = []) { static $instance; if (is_null($instance) === false) { return $instance; } $config = array_merge(['enabled' => true, 'showBar' => true, 'editor' => 'subl://open?url=file://%file&line=%line', 'maxDepth' => 4, 'maxLength' => 1000, 'scream' => true, 'showLocation' => true, 'strictMode' => true, 'panels' => ['routing' => false, 'database' => true, 'view' => false, 'event' => false, 'session' => true, 'request' => true, 'auth' => false, 'terminal' => false]], $config); $config['enabled'] = Arr::get($config, 'enabled', false); $config['showBar'] = Arr::get($config, 'showBar', false); $mode = isset($config['enabled']) === false ? Debugger::DETECT : $config['enabled'] === true ? Debugger::DEVELOPMENT : Debugger::PRODUCTION; Debugger::enable($mode); $debugbar = new Debugbar($config); $debugbar->setup(); return $instance = $debugbar; }
/** * dispatchContent. * * @method dispatchContent * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return \Symfony\Component\HttpFoundation\Response */ protected function dispatchContent($request, $next) { $this->storeWrapper->start(); $this->debugbar->dispatchContent(); $response = $this->debugbar->render($next($request)); $this->storeWrapper->store()->close(); return $response; }
/** * handle. * * @method handle * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return \Symfony\Component\HttpFoundation\Response */ public function handle($request, $next) { if ($request->has('_tracy_bar') === true) { $tracyBar = $request->get('_tracy_bar'); switch ($tracyBar) { case 'css': $content = $this->debugbar->dispatchAssets(); $headers = ['content-type' => 'text/css; charset=utf-8', 'cache-control' => 'max-age=86400']; break; case 'js': case 'assets': $content = $this->debugbar->dispatchAssets(); $headers = ['content-type' => 'text/javascript; charset=utf-8', 'cache-control' => 'max-age=86400']; break; default: $content = $this->debugbar->dispatch(); $headers = ['content-type' => 'text/javascript; charset=utf-8']; break; } return $this->sendStreamedResponse($content, array_merge($headers, ['content-length' => strlen($content)])); } $this->debugbar->dispatch(); return $next($request); }
/** * handle. * * @method handle * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return \Symfony\Component\HttpFoundation\Response */ public function handle($request, $next) { return $this->debugbar->render($next($request)); }