Request
class Request (View source)
Snapshot of the $_GET, $_POST and $_SERVER superglobals with typed accessors for controllers.
Properties
| protected array | $queryParams | ||
| protected array | $postParams | ||
| protected array | $serverParams |
Methods
Without arguments the request is a snapshot of the superglobals; given any, it is built from those arrays instead (tests, or a request assembled by hand).
Refreshes the request data from the global variables
No description
No description
No description
No description
Query string value as a string; $default when absent or not a string (?key[]=x).
POST body value as a string; $default when absent or not a string (key[]=x).
1-based page number from the query string, never below 1.
Requested page size from the query string, or null when absent or not a positive integer.
Returns a parameter from the POST body on POST requests, from the query string otherwise. For endpoints that accept both methods.
No description
No description
No description
Details
__construct(array|null $queryParams = null, array|null $postParams = null, array|null $serverParams = null)
Without arguments the request is a snapshot of the superglobals; given any, it is built from those arrays instead (tests, or a request assembled by hand).
void
refresh()
Refreshes the request data from the global variables
array
getQueryParams()
No description
array
getPostParams()
No description
getQueryParam(string $key, $default = null)
No description
getPostParam(string $key, $default = null)
No description
string
getQueryString(string $key, string $default = '')
Query string value as a string; $default when absent or not a string (?key[]=x).
string
getPostString(string $key, string $default = '')
POST body value as a string; $default when absent or not a string (key[]=x).
int
getPage(string $key = 'start')
1-based page number from the query string, never below 1.
int|null
getRowsPerPage(string $key = 'rows_per_page')
Requested page size from the query string, or null when absent or not a positive integer.
getParam(string $key, $default = null)
Returns a parameter from the POST body on POST requests, from the query string otherwise. For endpoints that accept both methods.
getServerParam(string $key, $default = null)
No description
string
getMethod()
No description
string
getUri()
No description