New responses can be made throught the Wolff Response
class.
Remember to use Core\Response
.
Creating a new Response:
$response = new Response();
The header
, remove
, setCode
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')
->setCode(200)
->redirect('https://getwolff.com')
->go();
Set the HTTP status code.
$response->setCode(200);
Returns the response HTTP status code.
$response->getCode();
Returns the response url.
$response->getRedirect();
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.
Returns all the response headers (as an associative array).
$response->getHeaders();
Remove a header if it exists.
$response->remove('Content-Type');
The parameter must be the desired header's key to delete.
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 existing status code).
$response->redirect('https://getwolff.com', 200);
Execute the response with all of its values.
$response->go();