![]() |
VOOZH | about |
class Request implements IRequest
Immutable representation of an HTTP request with access to URL, headers, cookies, uploaded files, and body.
| UrlScript read-only | $url |
| array<string,mixed> read-only | $query |
| array<string,mixed> read-only | $post |
| array<string,mixed> read-only | $files |
| array<string,string> read-only | $cookies |
| string read-only | $method |
| array<string,string> read-only | $headers |
| UrlImmutable read-only | $referer |
| bool read-only | $secured |
| bool read-only | $ajax |
| ?string read-only | $remoteAddress |
| ?string read-only | $rawBody |
No description
Returns a URL query parameter, or all parameters as an array if no key is given.
Returns a POST parameter, or all POST parameters as an array if no key is given.
Returns the uploaded file for the given key, or null if not present.
Returns the tree of uploaded files, with each leaf being a FileUpload instance.
Returns a cookie or null if it does not exist.
Returns all cookies.
Returns the HTTP method with which the request was made (GET, POST, HEAD, PUT, ...).
Checks the HTTP method with which the request was made. The parameter is case-insensitive.
Returns an HTTP header or null if it does not exist. The parameter is case-insensitive.
Returns all HTTP headers as associative array.
No description
Returns the request origin (scheme + host + port) from the Origin header, or null if absent or invalid.
Checks whether the request was sent via a secure channel (HTTPS).
Checks whether the request originated from your own site (same-site), i.e. it was not triggered from a foreign website. Serves as a CSRF-like protection for forms and signals.
Checks whether the request matches the given Sec-Fetch-Site, Sec-Fetch-Dest and Sec-Fetch-User values.
Checks whether the request was made via AJAX (X-Requested-With: XMLHttpRequest).
Returns the IP address of the remote client.
Returns raw content of HTTP request body.
Returns basic HTTP authentication credentials.
Returns the most preferred language from the Accept-Language header that matches one of the supported languages, or null if no match is found.
__construct(UrlScript $url, array $post = [], array $files = [], array $cookies = [], array $headers = [], string $method = 'GET', string|null $remoteAddress = null, callable|null $rawBodyCallback = null)
No description
| UrlScript | $url |
| array | $post |
| array | $files |
| array | $cookies |
| array | $headers |
| string | $method |
| string|null | $remoteAddress |
| callable|null | $rawBodyCallback |
mixed
getQuery(string|null $key = null)
Returns a URL query parameter, or all parameters as an array if no key is given.
| string|null | $key |
| mixed |
mixed
getPost(string|null $key = null)
Returns a POST parameter, or all POST parameters as an array if no key is given.
| string|null | $key |
| mixed |
FileUpload|null
getFile(string $key)
Returns the uploaded file for the given key, or null if not present.
Accepts a string key or an array of keys for nested file structures (e.g. ['form', 'avatar']).
| string | $key |
| FileUpload|null |
array
getFiles()
Returns the tree of uploaded files, with each leaf being a FileUpload instance.
| array |
mixed
getCookie(string $key)
Returns a cookie or null if it does not exist.
| string | $key |
| mixed |
array
getCookies()
Returns all cookies.
| array |
string
getMethod()
Returns the HTTP method with which the request was made (GET, POST, HEAD, PUT, ...).
| string |
bool
isMethod(string $method)
Checks the HTTP method with which the request was made. The parameter is case-insensitive.
| string | $method |
| bool |
string|null
getHeader(string $header)
Returns an HTTP header or null if it does not exist. The parameter is case-insensitive.
| string | $header |
| string|null |
array
getHeaders()
Returns all HTTP headers as associative array.
| array |
UrlImmutable|null
getReferer()
No description
| UrlImmutable|null |
UrlImmutable|null
getOrigin()
Returns the request origin (scheme + host + port) from the Origin header, or null if absent or invalid.
| UrlImmutable|null |
bool
isSecured()
Checks whether the request was sent via a secure channel (HTTPS).
| bool |
bool
isSameSite()
deprecated
deprecated use isFrom()
Checks whether the request originated from your own site (same-site), i.e. it was not triggered from a foreign website. Serves as a CSRF-like protection for forms and signals.
| bool |
bool
isFrom(FetchSite> $site, FetchDest>|null $dest = null, ?bool $user = null)
Checks whether the request matches the given Sec-Fetch-Site, Sec-Fetch-Dest and Sec-Fetch-User values.
| FetchSite> | $site |
| FetchDest>|null | $dest |
| ?bool | $user |
| bool |
bool
isAjax()
Checks whether the request was made via AJAX (X-Requested-With: XMLHttpRequest).
| bool |
string|null
getRemoteAddress()
Returns the IP address of the remote client.
| string|null |
string|null
getRawBody()
Returns raw content of HTTP request body.
| string|null |
array|null
getBasicCredentials()
Returns basic HTTP authentication credentials.
| array|null |
string|null
detectLanguage(array $langs)
Returns the most preferred language from the Accept-Language header that matches one of the supported languages, or null if no match is found.
| array | $langs | supported language codes (e.g. ['en', 'cs', 'de']) |
| string|null |