Class JsonResponse
This is a simple abstraction over top an HTTP response. This provides methods to set the HTTP status, the HTTP headers, and the HTTP body. Please use this response only if you want to send a JSON response.
$response = new Docolight\Http\JsonResponse(new Docolight\Http\Headers()); // Or you can resolve via factory // $response = with(new Docolight\Http\ResponseFactory())->produce('json'); // Move even shorter way // $response = container('response')->produce('json'); // Set your header $response->headers->set('Foo', 'Bar'); // Set your response status $response->setStatus(202); // Set your response body $response->setBody(new Docolight\Support\Fluent(array('my_json_index' => 'my_json_value'))); // Send your response to client $response->send(); // In shorter way // response( // 'json', // 200, // new Docolight\Support\Fluent(array('my_json_index' => 'my_json_value')), // array('Foo' => 'Bar') // )->send();
- CApplicationComponent
- Docolight\Http\Response implements ArrayAccess
- Docolight\Http\MimeResponse
- Docolight\Http\JsonResponse
Namespace: Docolight\Http
Author: Krisan Alfa Timur krisanalfa@docotel.co.id
Located at Docolight/Http/JsonResponse.php
Author: Krisan Alfa Timur krisanalfa@docotel.co.id
Located at Docolight/Http/JsonResponse.php
Methods summary
public
|
|
protected
string
|
|
protected
string
|
#
convertToStringRepresentation(
Convert to a string representation. |
protected
mixed
|
Methods inherited from Docolight\Http\MimeResponse
Methods inherited from Docolight\Http\Response
__construct()
,
getLength()
,
getMessageForCode()
,
getStatus()
,
offsetExists()
,
offsetGet()
,
offsetSet()
,
offsetUnset()
,
prepareHeaders()
,
redirect()
,
send()
,
setBody()
,
setMessage()
,
setStatus()