I\'m developing a REST api with Symfony2 + FOSRest bundle.
I would like to know if there is any way for a call to the api in dev mode (app_dev.php
) from the
I use my WithProfilerTrait
which applies the toolbar only if you navigate to the URL in the browser and skips the change, if it's an ajax request.
// in Controller:
return $this->withProfiler($response, $request->isXmlHttpRequest());
trait WithProfilerTrait
{
protected function withProfiler(Response $response, bool $skip = false): Response
{
if ($skip === true) {
return $response;
}
$wrappedContent = '' . $response->getContent() . '
';
$response->headers->set('Content-Type', 'html');
return $response->setContent($wrappedContent);
}
}