Request

Instead of managing the superglobal arrays of PHP directly, Wolff gives you an abstraction layer throught the Request class.

# GET

Get

Getting a GET variable:

Request::get('name');

If no parameter is passed to the function, it will retrieve all the $_GET array content.

Has

Check if a GET variable exists:

Request::hasGet('name');

Set

Setting a GET variable:

Request::setGet('name');

Unset

Unset a GET variable:

Request::unsetGet('name');

If no parameter is passed to the function, all of the $_GET array content will be unset.

# POST

Get

Getting a POST variable:

Request::post('name');

If no parameter is passed to the function, it will retrieve all the $_POST array content.

Has

Check if a POST variable exists:

Request::hasPost('name');

Set

Setting a POST variable:

Request::setPost('name');

Unset

Unset a POST variable:

Request::unsetPost('name');

If no parameter is passed to the function, all of the $_POST array content will be unset.

# FILES

Get

Getting a FILE variable:

Request::file('name');

If no parameter is passed to the function, it will retrieve all of the $_FILES array content.

Has

Check if a FILE variable exists:

Request::hasFile('name');

# COOKIE

Get

Getting a COOKIE variable:

Request::cookie('name');

If no parameter is passed to the function, it will retrieve all the $_COOKIE array content.

Has

Check if a COOKIE variable exists:

Request::hasCookie('name');

Set

Setting a COOKIE variable:

Request::setCookie('name', 'value', 60);

The first parameter is the variable key, the second is the value, the third is the time expressed in seconds, the fourth and last value is the path where the variable will work, it's optional.

If the path is not specified, the cookie will be available in all of the page.

You can pass a string as the time too:

String Time
forever 5 Years from now
month 30 days from now
day 24 hours from now

Example:

Request::setCookie('user_id', '1234', 'forever', 'profile/');

The user_id variable will be available for the next 5 years only in the 'profile' pages.

Unset

Unset a COOKIE variable:

Request::unsetGet('name');

If no parameter is passed to the function, all of the $_COOKIE array content will be unset.