I am using the HttpFoundation in my small project: use \Symfony\Component\HttpFoundation\JsonResponse as JsonResponse;
Unfortunately all my responses (tried JsonResponse
, Response
and BinaryFileResponse
) only return a blank page, no errors and the code gets executed normally, e.g.
/* Get Inputs */
if (!$data = filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL)) {
return new JsonResponse(array(
'result' => 'error',
'message' => 'URL is invalid or missing'
));
}else{
return new JsonResponse(array(
'result' => 'success',
'message' => 'FINE'
));
There are no errors in the logs either.
Any ideas how to approach the issue?
//UPDATE FOR CLARIFICATION
$json = new JsonResponse(array(
'result' => 'error',
'message' => 'Encrypt is invalid or missing'
));
echo $json;
returns HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json {"result":"error","message":"Encrypt is invalid or missing"}
but why does the return
not work?
You're not using the full stack framework, so you need to be sure that your front controller or equivalent calls $response->send();
to deliver the response to the client.