Example #1
0
/**
 * Sends a response as json with a status code.
 *
 * @param array $data
 * @param int $status
 */
function respondJson($data = [], $status = HTTP_OK)
{
    $encoded = utf8_encode_array($data);
    $response = new Symfony\Component\HttpFoundation\JsonResponse($encoded, $status);
    $response->setEncodingOptions(JSON_NUMERIC_CHECK);
    $response->send();
}