Request
API reference › yii › console › Request
The console Request represents the environment information for a console application.
It is a wrapper for the PHP $_SERVER variable which holds information about the
currently running PHP script and the command line arguments given to it.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
$isConsoleRequest | bool | The value indicating whether the current request is made via console. | yii\ |
$params | array | The command line arguments. | Request |
$scriptFile | string | Entry script file path (processed w/ realpath()). | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
getBehavior() | Returns the named behavior object. | yii\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
getIsConsoleRequest() | Returns a value indicating whether the current request is made via command line. | yii\ |
getParams() | Returns the command line arguments. | Request |
getScriptFile() | Returns entry script file path. | yii\ |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
init() | Initializes the object. | yii\ |
off() | Detaches an existing event handler from this component. | yii\ |
on() | Attaches an event handler to an event. | yii\ |
resolve() | 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. | yii\ |
setParams() | Sets the command line arguments. | Request |
setScriptFile() | Sets the entry script file path. | yii\ |
trigger() | Triggers an event. | yii\ |
Property details
Section titled “Property details”$params
Section titled “$params ”public array $paramsThe command line arguments.
It does not include the entry script name.
Method details
Section titled “Method details”getParams()
Section titled “getParams() ”public function getParams(): arrayReturns the command line arguments.
Returns
array: The command line arguments. It does not include the entry script name.
resolve()
Section titled “resolve() ”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.
Throws
Exception: when parameter is wrong and can not be resolved
setParams()
Section titled “setParams() ”public function setParams(array $params): mixedSets the command line arguments.
Parameters
| Parameter | Type | Description |
|---|---|---|
$params | array | The command line arguments |
Returns
mixed