public function onResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $debug = $request->query->get('debug');
        $response = $event->getResponse();

        //this is for debug purpose
        if ($response instanceof JsonResponse && $debug) {
            $new = new Response();
            $new->setContent('<body>'.$response->getContent().'</body>');
            $event->setResponse($new);
        }
    }
public function onResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $debug = $request->query->get('debug');
        $response = $event->getResponse();

        //this is for debug purpose
        if ($response instanceof JsonResponse && $debug) {
            $new = new Response();
            $new->setContent('<body>'.$response->getContent().'</body>');
            $event->setResponse($new);
        }
    }
public function onResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ debug = $ request -> query -> get ( 'debug' ) ; $ response = $ event -> getResponse ( ) ; //this is for debug purpose if ( $ response instanceof JsonResponse && $ debug ) { $ new = new Response ( ) ; $ new -> setContent ( '<body>' . $ response -> getContent ( ) . '</body>' ) ; $ event -> setResponse ( $ new ) ; } }
If we're returning a JsonResponse, we can get the debug bar by passing ?debug=true on the query string.

@DI\Observe("kernel.response")

@param FilterResponseEvent $event
If we re returning a JsonResponse we can get the debug bar by passing ?debug = true on the query string .