Request
API reference › yii › base › Request
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$behaviors read-only | array<Behavior<static>> | List of behaviors attached to this component. | Component |
$isConsoleRequest | bool | The value indicating whether the current request is made via console. | Request |
$scriptFile | string | Entry script file path (processed w/ realpath()). | Request |
Methods
Section titled “Methods”| Method | Description | Defined 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() static | Returns 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() abstract | Resolves 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 |
Method details
Section titled “Method details”getIsConsoleRequest()
Section titled “getIsConsoleRequest() ”public function getIsConsoleRequest(): boolReturns 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
getScriptFile()
Section titled “getScriptFile() ”public function getScriptFile(): stringReturns entry script file path.
Returns
string: Entry script file path (processed w/ realpath())
Throws
InvalidConfigException: if the entry script file path cannot be determined automatically.
resolve()
Section titled “resolve() ”abstract public function resolve(): arrayResolves 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.
setIsConsoleRequest()
Section titled “setIsConsoleRequest() ”public function setIsConsoleRequest(bool $value): mixedSets the value indicating whether the current request is made via command line.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | bool | The value indicating whether the current request is made via command line |
Returns
mixed
setScriptFile()
Section titled “setScriptFile() ”public function setScriptFile(string $value): mixedSets 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
| Parameter | Type | Description |
|---|---|---|
$value | string | The entry script file path. This can be either a file path or a path alias. |
Returns
mixed
Throws
InvalidConfigException: if the provided entry script file path is invalid.