class Response implements ResponseInterface (View source)

Methods

static Response
getInstance()

Get response

int
getCode()

Get status code

string
download(string $file, string|null $filename = null, array $headers = [])

Download the given file as an argument

withHeaders(array $headers)

Add http headers

withHeader(string $key, string $value)

Add http header

withCookie(string $key, string $value)

Set cookie header

withCookies(array $cookies)

Set multiple cookies

array
getHeaders()

Get headers

string|null
getContent()

Get response message

setContent(string $content)

Get response message

status(int $code)

Modify http headers

string
send(mixed $data, int $code = 200, array $headers = [])

Equivalent to an echo, except that it ends the application

string
json(mixed $data, int $code = 200, array $headers = [])

JSON response

string
render(string $template, array $data = [], int $code = 200, array $headers = [])

Make view rendering

getServerAccessControl()

Modify the service access control from ServerAccessControl instance

void
sendContent()

No description

Details

static Response getInstance()

Get response

Return Value

Response

int getCode()

Get status code

Return Value

int

string download(string $file, string|null $filename = null, array $headers = [])

Download the given file as an argument

Parameters

string $file
string|null $filename
array $headers

Return Value

string

Response withHeaders(array $headers)

Add http headers

Parameters

array $headers

Return Value

Response

Response withHeader(string $key, string $value)

Add http header

Parameters

string $key
string $value

Return Value

Response

Response withCookie(string $key, string $value)

Set cookie header

Parameters

string $key
string $value

Return Value

Response

Response withCookies(array $cookies)

Set multiple cookies

Parameters

array $cookies

Return Value

Response

array getHeaders()

Get headers

Return Value

array

string|null getContent()

Get response message

Return Value

string|null

Response setContent(string $content)

Get response message

Parameters

string $content

Return Value

Response

Response status(int $code)

Modify http headers

Parameters

int $code

Return Value

Response

string send(mixed $data, int $code = 200, array $headers = [])

Equivalent to an echo, except that it ends the application

Parameters

mixed $data
int $code
array $headers

Return Value

string

string json(mixed $data, int $code = 200, array $headers = [])

JSON response

Parameters

mixed $data
int $code
array $headers

Return Value

string

string render(string $template, array $data = [], int $code = 200, array $headers = [])

Make view rendering

Parameters

string $template
array $data
int $code
array $headers

Return Value

string

Exceptions

ServerAccessControl getServerAccessControl()

Modify the service access control from ServerAccessControl instance

Return Value

ServerAccessControl

void sendContent()

No description

Return Value

void