use Symfony\Component\HttpFoundation\Response; $response = new Response(); $response->setContent(json_encode([ 'data' => 123, ])); $response->headers->set('Content-Type', 'application/json');

symfony set content type

Similar Code Examples