The Request class is used to create and manage new and existing requests.

There is a main request which comes in from the browser or command line, then new requests can be created for HMVC requests.

Example Usage:

$request = Request::forge('foo/bar')->execute();
echo $request->response();

package Fuel
subpackage Core

 Methods

Creates the new Request object by getting a new URI object, then parsing the uri with the Route class.

__construct(string $uri, bool $route, string $method) 

Usage:

$request = new Request('foo/bar');

Parameters

$uri

string

the uri string

$route

bool

whether or not to route the URI

$method

string

request method

Exceptions

\FuelException

PHP magic function returns the Output of the request.

__toString() : string

Usage:

$request = Request::forge('hello/world')->execute();
echo $request;

Returns

stringthe response

Returns the active request currently being used.

active(\Fuel\Core\Request | null | false $request) : \Fuel\Core\Request

Usage:

Request::active();

Parameters

$request

\Fuel\Core\Requestnullfalse

overwrite current request before returning, false prevents overwrite

Returns

Add to paths which are used by Finder::search()

add_path(string $path, bool $prefix) : void

Parameters

$path

string

the new path

$prefix

bool

whether to add to the front or the back of the array

Returns an array of Requests created by this one

children() : array

Returns

array

This executes the request and sets the output to be used later.

execute(array | null $method_params) : \Fuel\Core\Request

Usage:

$request = Request::forge('hello/world')->execute();

Parameters

$method_params

arraynull

An array of parameters to pass to the method being executed

Exceptions

\Exception
\FuelException
\HttpNotFoundException

Returns

\Fuel\Core\RequestThis request object

Generates a new request.

forge(string $uri, mixed $options, string $method) : \Fuel\Core\Request

The request is then set to be the active request. If this is the first request, then save that as the main request for the app.

Usage:

Request::forge('hello/world');

Parameters

$uri

string

The URI of the request

$options

mixed

Internal: whether to use the routes; external: driver type or array with settings (driver key must be set)

$method

string

request method

Returns

\Fuel\Core\RequestThe new request object

Returns the request method.

get_method() : string

Returns

stringrequest method

Returns the array of currently loaded search paths.

get_paths() : array

Returns

arraythe array of paths

Returns this Requests Input object

input() : \Fuel\Core\Input

Returns the current request is an HMVC request

is_hmvc() : bool

Usage:

if (Request::is_hmvc())
{
    // Do something special...
    return;
}

Returns

bool

Returns the main request instance (the one from the browser or CLI).

main() : \Fuel\Core\Request

This is the first executed Request, not necessarily the root parent of the current request.

Usage:

Request::main();

Returns

Gets a specific named parameter

param(string $param, mixed $default) : mixed

Parameters

$param

string

Name of the parameter

$default

mixed

Default value

Returns

mixed

Gets all of the named parameters

params() : array

Returns

array

Returns the Request that created this one

parent() : \Fuel\Core\Request | null

Returns

Reset's the active request with the previous one.

reset_request($full) : void

This is needed after the active request is finished.

Usage:

Request::reset_request();

Parameters

$full

Gets this Request's Response object;

response() : \Fuel\Core\Response

Usage:

$response = Request::forge('foo/bar')->execute()->response();

Returns

\Fuel\Core\ResponseThis Request's Response object

set additional DELETE input variables

set_delete($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

set additional GET input variables

set_get($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

set additional JSON input variables

set_json($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

Sets the request method.

set_method(string $method) : object

Parameters

$method

string

request method

Returns

objectcurrent instance

set additional PATCH input variables

set_patch($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

set additional POST input variables

set_post($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

set additional PUT input variables

set_put($var, $value) : \Fuel\Core\Input

Parameters

$var

$value

Returns

 Properties

 

The request's controller action

$action : string

 

The request's controller

$controller : string

 

Controller instance once instantiated

$controller_instance : \Fuel\Core\Controller

 

The current controller directory

$directory : string

 

The request's method params

$method_params : array

 

The current module

$module : string

 

The request's named params

$named_params : array

 

Search paths for the current active request

$paths : array

 

Holds the response object of the request.

$response : \Fuel\Core\Response

 

The request's route object

$route : \Fuel\Core\Route

 

The Request's URI object.

$uri : \Fuel\Core\Uri

 

Holds the global active request instance

$active : \Fuel\Core\Request

 

Requests created by this request

$children : array

 

The Request's INPUT object.

$input : \Fuel\Core\Input_Instance

 

Holds the main request instance

$main : \Fuel\Core\Request

 

<p>request method</p>

$method : string

 

Request that created this one

$parent : \Fuel\Core\Request