PHP Class System\Response

Exibir arquivo Open project: rwarasaurus/nano Class Usage Examples

Public Properties

Property Type Description
$headers array Array of headers to be sent
$output string The final output
$status integer The response status

Public Methods

Method Description
__construct ( $output, $status = 200, $headers = [] ) Create a new instance of the Response class
create ( $output, $status = 200, $headers = [] ) : object Create a new instance of the Response class for chaining
json ( $output, $status = 200 ) : object Creates a response with the output as JSON
redirect ( $uri, $status = 302 ) : object Creates a response with a header to redirect
send ( ) Sends the final headers cookies and output

Method Details

__construct() public method

Create a new instance of the Response class
public __construct ( $output, $status = 200, $headers = [] )

create() public static method

Create a new instance of the Response class for chaining
public static create ( $output, $status = 200, $headers = [] ) : object
return object

json() public static method

Creates a response with the output as JSON
public static json ( $output, $status = 200 ) : object
return object

redirect() public static method

Creates a response with a header to redirect
public static redirect ( $uri, $status = 302 ) : object
return object

send() public method

Sends the final headers cookies and output
public send ( )

Property Details

$headers public_oe property

Array of headers to be sent
public array $headers
return array

$output public_oe property

The final output
public string $output
return string

$status public_oe property

The response status
public int $status
return integer