-
Notifications
You must be signed in to change notification settings - Fork 1
Request
This class simplifies access to request parameters, along with a number of validation methods.
No configuration needed: simply create a new instance of the Request class.
$request = new \AppUtils\Request();
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');
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.