Skip to content
PHP Ecosystem
Explore

Request

API reference › yii › base › Request

abstract classyii\base\Request
ExtendsComponent » BaseObject
ImplementsConfigurable
Since2.0
Sourceframework/base/Request.php
2 subclasses

Request represents a request that is handled by an Application.

For more details and usage information on Request, see the guide article on requests.

PropertyTypeDescriptionDefined by
$behaviors read-onlyarray<Behavior<static>>List of behaviors attached to this component.Component
$isConsoleRequestboolThe value indicating whether the current request is made via console.Request
$scriptFilestringEntry script file path (processed w/ realpath()).Request
MethodDescriptionDefined by
__construct()Constructor.BaseObject
__call()Calls the named method which is not a class method.Component
__clone()This method is called after the object is created by cloning an existing one.Component
__get()Returns the value of a component property.Component
__isset()Checks if a property is set, i.e. defined and not null.Component
__set()Sets the value of a component property.Component
__unset()Sets a component property to be null.Component
attachBehavior()Attaches a behavior to this component.Component
attachBehaviors()Attaches a list of behaviors to the component.Component
behaviors()Returns a list of behaviors that this component should behave as.Component
canGetProperty()Returns a value indicating whether a property can be read.Component
canSetProperty()Returns a value indicating whether a property can be set.Component
className() staticReturns the fully qualified name of this class.BaseObject
detachBehavior()Detaches a behavior from the component.Component
detachBehaviors()Detaches all behaviors from the component.Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.Component
getBehavior()Returns the named behavior object.Component
getBehaviors()Returns all behaviors attached to this component.Component
getIsConsoleRequest()Returns a value indicating whether the current request is made via command line.Request
getScriptFile()Returns entry script file path.Request
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.Component
hasMethod()Returns a value indicating whether a method is defined.Component
hasProperty()Returns a value indicating whether a property is defined for this component.Component
init()Initializes the object.BaseObject
off()Detaches an existing event handler from this component.Component
on()Attaches an event handler to an event.Component
resolve() abstractResolves the current request into a route and the associated parameters.Request
setIsConsoleRequest()Sets the value indicating whether the current request is made via command line.Request
setScriptFile()Sets the entry script file path.Request
trigger()Triggers an event.Component
public function getIsConsoleRequest(): bool

Returns a value indicating whether the current request is made via command line.

Returns

bool: The value indicating whether the current request is made via console

public function getScriptFile(): string

Returns entry script file path.

Returns

string: Entry script file path (processed w/ realpath())

Throws

abstract public function resolve(): array

Resolves the current request into a route and the associated parameters.

Returns

array: The first element is the route, and the second is the associated parameters.

public function setIsConsoleRequest(bool $value): mixed

Sets the value indicating whether the current request is made via command line.

Parameters

ParameterTypeDescription
$valueboolThe value indicating whether the current request is made via command line

Returns

mixed

public function setScriptFile(string $value): mixed

Sets the entry script file path.

The entry script file path can normally be determined based on the SCRIPT_FILENAME SERVER variable. However, for some server configurations, this may not be correct or feasible. This setter is provided so that the entry script file path can be manually specified.

Parameters

ParameterTypeDescription
$valuestringThe entry script file path. This can be either a file path or a path alias.

Returns

mixed

Throws