Request
Reads request parameters through one centralized interface, checking POST, GET and COOKIE in that order.
Lookup priority
The lookup order is POST → GET → COOKIE. When a key exists in more than one source, the
first matching source wins. For explicit source selection, use Core\Post,
Core\Get
or Core\Cookie.
No direct superglobals
Do not read $_POST, $_GET or $_COOKIE directly in application
code.
Example
$request = Registry::get(Request::class);
$page = $request->getInt('page');
Public API Reference
Core\Request
Class & Registry
Class:
Core\Request
Extends:
Core\Request\Base
use Core\Request;
use Core\Registry;
$request = Registry::get(Request::class);
| Method | Description |
|---|---|
init():void |
Initializes the request controller by resolving the POST, GET and COOKIE controllers from the Registry. |
get(string $key):mixed |
Returns a request parameter using POST, GET and COOKIE priority, or null if
the key does not exist.
|
getString(string $key, string $default = ''):string |
Returns a request parameter as a string using POST, GET and COOKIE priority, or the specified default if the key is missing. |
getInt(string $key, int $default = 0):int |
Returns a request parameter as an integer using POST, GET and COOKIE priority, or the specified default if the key is missing. |
getFloat(string $key, float $default = 0.0):float |
Returns a request parameter as a float using POST, GET and COOKIE priority, or the specified default if the key is missing. |
getBool(string $key, bool $default = false):bool |
Returns a request parameter as a boolean using POST, GET and COOKIE priority, or the specified default if the key is missing. |
getArray(string $key, array $default = []):array |
Returns a request parameter as an array using POST, GET and COOKIE priority, or the specified default if the key is missing. |
getAll():array |
Returns all request parameters merged from COOKIE, GET and POST, with higher-priority sources overwriting matching keys. |
has(string $key):bool |
Checks whether a request parameter exists in POST, GET or COOKIE data. |