Response

New responses can be made throught the Response class. First you need to use Core\Response in your class, then you can use the following methods.

# Basics

Creating a new Response:

$response = new Response();

The header, remove, setStatusCode and redirect methods can be used as chained methods. Making the process of creating a new Response easier and quicker.

$response->header('Content-Type', 'text/html; charset=utf-8')
         ->setStatusCode(200)
         ->redirect('https://getwolff.com')
         ->go();

# Methods

getHeaders

Returns all the response headers (as an associative array).

$response->getHeaders();

getStatusCode

Returns the response HTTP status code.

$response->getStatusCode();

getRedirect

Returns the response url.

$response->getRedirect();

header

Add a new header to the response.

$response->header('Content-Type', 'text/html; charset=utf-8');

The first parameter is the header's key, the second is the header's value.

remove

Remove a header if it exists.

$response->remove('Content-Type');

The parameter must be the desired header's key to delete.

setStatusCode

Set the HTTP status code.

$response->setStatusCode(200);

redirect

Set the Response's url.

$response->redirect('https://getwolff.com');

The HTTP status code can be pass as an optional second parameter (this will overwrite the previous status code).

$response->redirect('https://getwolff.com', 200);

go

Execute the response with all of its values.

$response->go();