Skip to content

Request

Mistralys edited this page Oct 25, 2019 · 4 revisions

The Request class

This class simplifies access to request parameters, along with a number of validation methods.

Configuration

No configuration needed: simply create a new instance of the Request class.

$request = new \AppUtils\Request();

Getting parameters

The basic way is to access parameters without any validation:

$param = $request->getParam('foo');

By default, if a parameter does not exist, this will return NULL. You can specify a default value instead:

// if the parameter does not exist, return `bar`
$param = $request->getParam('foo', 'bar');

Validating parameters

To validate parameters, you have to register them. Once registered, the validation will be applied automatically every time you with to access it.

For example, if you have a parameter that contains an integer:

$request->registerParam('myparam')->setInteger();
$int = $request->getParam('myparam');

New here?

Have a look at the overview for a list of all helper classes available in the package.

Table of contents

Find the current page in the collapsible "Pages" list above, and expand the page, to view a table of contents.

Clone this wiki locally