Sapi
in package
PHP SAPI.
This object is responsible for:
- Constructing a Request object based on the current HTTP request sent to the PHP process.
- Sending the Response object back to the client.
It could be said that this class provides a mapping between the Request and Response objects, and php's:
- $_SERVER
- $_POST
- $_FILES
- php://input
- echo()
- header()
- php://output
You can choose to either call all these methods statically, but you can also instantiate this as an object to allow for polymorhpism.
Tags
Table of Contents
- createFromServerArray() : Request
- This static method will create a new Request object, based on a PHP $_SERVER array.
- getRequest() : Request
- This static method will create a new Request object, based on the current PHP request.
- sendResponse() : mixed
- Sends the HTTP response back to a HTTP client.
Methods
createFromServerArray()
This static method will create a new Request object, based on a PHP $_SERVER array.
public
static createFromServerArray(array<string|int, mixed> $serverArray) : Request
REQUEST_URI and REQUEST_METHOD are required.
Parameters
- $serverArray : array<string|int, mixed>
Return values
Request —getRequest()
This static method will create a new Request object, based on the current PHP request.
public
static getRequest() : Request
Return values
Request —sendResponse()
Sends the HTTP response back to a HTTP client.
public
static sendResponse(ResponseInterface $response) : mixed
This calls php's header() function and streams the body to php://output.
Parameters
- $response : ResponseInterface