HTTP Request Component

Request Environment

Every HTTP request (usually originated by a browser) contains additional information regarding the request such as header data, files, variables, etc. A web based application needs to parse that information in order to perform a particular action and send the correct response back to the requester. Phalcon\Http\Request encapsulates the request information in a simple value object.


use Phalcon\Http\Request;

// Getting a request instance
$request = new Request();

// Check whether the request was made with method POST
if (true === $request->isPost()) {
    // Check whether the request was made with Ajax
    if (true === $request->isAjax()) {
        echo 'Request was made using POST and AJAX';