Responses

Responses are HTTP messages and/or data sent from web server.

In the Quantum framework responses are managed by Response class, which extends the base HttpResponse class. Responses can be outputted from server in different forms and contain special HTTP status code (like 301, 404, 500, etc.).

The Response class has several methods to sent header information:

  • Response::setHeader($key, $value) - Sets new header information by given key and value
  • Response::setCSRFToken($csrfToken) - Sets Сross Site Request Forgery Token
  • Response::setContentType($contentType) - Sets the content type
  • Response::setStatus($status) - Sets the HTTP status code

The Response class has also several methods to return or output the content:

  • Response::json($data, $status = NULL) - Returns JSON encoded data
  • Response::jsonOutput($data, $status = NULL) - responses.json_output
  • Response::xml(array $arr) - Outputs reponse in XML format
<< Prev Next >>