Skip to content
Tommy Teasdale edited this page Dec 6, 2015 · 7 revisions

The ApineRequest class 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 manage some pre-validation on inputs.

Usage Example

if (!ApineRequest::is_api_call()) {
    if (!empty(ApineRequest::get()['request']) && ApineRequest::get()['request'] != '/') {
        $request = ApineRequest::get()['request'];
    } else {
        $request = '/index';
    }

    if (ApineRequest::is_get()) {
        // Do something if the HTTP verb is GET
    } else if (ApineRequest::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 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