Request - ApinePHP/legacy-framework GitHub Wiki
The Request Utility is a object-oriented representation of the current http request and user inputs. It is used to get information about the current http request in a concise and comprehensible way. It acts as a facade for both PHP superarrays. It even executes some pre-validation on inputs.
To access the request utility, you must import the Request class from the Core module.
use Apine\Core\Request;
Usage Example
if (!Request::is_api_call()) {
if (!empty(Request::get()['request']) && Request::get()['request'] != '/') {
$request = Request::get()['request'];
} else {
$request = '/index';
}
if (Request::is_get()) {
// Do something if the HTTP verb is GET
} else if (Request::is_post()) {
// Do something else if the verb is POST
}
}
Methods
Verify request status
static is_get() : bool
Returns weither the current http request is a GET request or not
static is_post() : bool
Returns weither the current http request is a POST request or not
static is_put() : bool
Returns weither the current http request is a PUT request or not
static is_delete() : bool
Returns weither the current http request is a DELETE request or not
static get_request_type() : string
Return the type of the current http request
static get_request_port() : integer
Return the port used by the user in the current request
static get_request_headers() : array
Return headers received from the current request
static get_request_body() : string
Return the raw body from the current request
static is_https() : bool
Checks if the request is made through the HTTPS protocol
static is_api_call() : bool
Checks if the request is made to the API
static is_ajax() : bool
Checks if the request is made from a ajax client
Get User Inputs
static get() : array
Return GET input
static post() : array
Return POST input
static files() : array
Return uploaded file input
static request() : array
Return Request information
static server() : array
Return server information
static get_request_params() : array
Return an aggregate of all the input that are sent directly to the controllers through the routing procedure