Simple library to abstract requests (CLI, HTTP, etc.)

v1.5.3 2023-05-31 23:34 UTC

This package is auto-updated.

Last update: 2023-06-01 10:55:45 UTC


Simple library to abstract request information and validate user input.

Built on ValidArray, it not only provides access to main request information, but integrates input arguments filtering. This allows for simplified access to validated request parameters as in the example below:


$request = new \Vertilia\Request\HttpRequest(
        'id' => ['filter' => \FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]],
        'name' => \FILTER_DEFAULT,
        'email' => \FILTER_VALIDATE_EMAIL,
        'profile' => ['filter' => \FILTER_VALIDATE_URL, 'flags' => \FILTER_FLAG_HOST_REQUIRED],


In the example above, $request is initialised with HTTP request data, defines input argument filters and tries to retrieve them from HTTP headers, cookies, POST and GET parameters. In case of other HTTP method used, it parses php://input based on Content-Type HTTP header. All found arguments are then validated following the given filters.

Input validation guarantees that user data is of specified type. Input arguments not mentionned in filters list are ignored. Arguments that do not match filters are set to false. Missing arguments are set to null.

Employed filtering mechanism is standard php extension since php-5.2.

See PHP Filter extension.