PhpNativeServer
in package
implements
Server
Class PhpNativeServer
Implementation of the Server interface using PHP's native global variables ($_SERVER
, $_POST
, $_GET
).
Acts as a bridge between the application and the PHP environment, allowing access to the request data
and sending responses through native PHP functions.
Table of Contents
Interfaces
- Server
- Interface Server
Methods
- getRequest() : Request
- Get request sent by the client.
- getRequestData() : array<string|int, mixed>
- Retrieves and parses the request data based on the request method and content type.
- sendResponse() : void
- Sends the provided HTTP response to the client.
- uploadedFiles() : array<string, File>
- Retrieves uploaded files from the $_FILES superglobal and returns them as an array of File objects.
Methods
getRequest()
Get request sent by the client.
public
getRequest() : Request
Tags
Return values
RequestgetRequestData()
Retrieves and parses the request data based on the request method and content type.
public
getRequestData() : array<string|int, mixed>
- For POST requests with a non-JSON content type, returns the $_POST array.
- For requests with 'application/json' content type, decodes the JSON payload and returns it as an associative array.
- For other content types, parses the raw input and returns it as an array.
Return values
array<string|int, mixed> —The parsed request data as an associative array.
sendResponse()
Sends the provided HTTP response to the client.
public
sendResponse(Response $response) : void
Parameters
- $response : Response
-
The response object to be sent.
Tags
uploadedFiles()
Retrieves uploaded files from the $_FILES superglobal and returns them as an array of File objects.
public
uploadedFiles() : array<string, File>
Iterates over each entry in $_FILES, and for each file with a non-empty 'tmp_name', creates a new File instance containing the file's contents, MIME type, and original name.
Return values
array<string, File> —An associative array of File objects, keyed by the input field name.