new(Json)回复显示空白页面(Symfony HttpFoundation)

时间:2015-12-15 12:48:58

标签: php symfony response psr-7 symfony-http-foundation

我在我的小项目中使用HttpFoundation:use \Symfony\Component\HttpFoundation\JsonResponse as JsonResponse;

不幸的是,我的所有回复(已尝试JsonResponseResponseBinaryFileResponse)仅返回空白页,没有错误,代码正常执行,例如

/* 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'
    ));

日志中也没有错误。

任何想法如何处理这个问题?

//澄清更新

$json = new JsonResponse(array(
    'result' => 'error',
    'message' => 'Encrypt is invalid or missing'
));

echo $json;

返回HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json {"result":"error","message":"Encrypt is invalid or missing"}

但为什么return不起作用?

0 个答案:

没有答案