# Request

> The console Request represents the environment information for a console application.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [console](/docs/api/yii/console/index.md) › Request

| class | `yii\console\Request` |
| --- | --- |
| Extends | [`yii\base\Request`](/docs/api/yii/base/request/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Since | 2.0 |
| Source | [`framework/console/Request.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/console/Request.php#L22) |

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

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-isConsoleRequest"></span>[`$isConsoleRequest`](/docs/api/yii/base/request/index.md#property-isConsoleRequest) | `bool` | The value indicating whether the current request is made via console. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| [`$params`](#property-params) | `array` | The command line arguments. | `Request` |
| <span id="property-scriptFile"></span>[`$scriptFile`](/docs/api/yii/base/request/index.md#property-scriptFile) | `string` | Entry script file path (processed w/ realpath()). | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getIsConsoleRequest"></span>[`getIsConsoleRequest()`](/docs/api/yii/base/request/index.md#method-getIsConsoleRequest) | Returns a value indicating whether the current request is made via command line. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| [`getParams()`](#method-getParams) | Returns the command line arguments. | `Request` |
| <span id="method-getScriptFile"></span>[`getScriptFile()`](/docs/api/yii/base/request/index.md#method-getScriptFile) | Returns entry script file path. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`resolve()`](#method-resolve) | Resolves the current request into a route and the associated parameters. | `Request` |
| <span id="method-setIsConsoleRequest"></span>[`setIsConsoleRequest()`](/docs/api/yii/base/request/index.md#method-setIsConsoleRequest) | Sets the value indicating whether the current request is made via command line. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| [`setParams()`](#method-setParams) | Sets the command line arguments. | `Request` |
| <span id="method-setScriptFile"></span>[`setScriptFile()`](/docs/api/yii/base/request/index.md#method-setScriptFile) | Sets the entry script file path. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |

## Property details

### $params <span id="property-params"></span>

```php
public array $params
```

The command line arguments.

It does not include the entry script name.

## Method details

### getParams() <span id="method-getParams"></span>

```php
public function getParams(): array
```

Returns the command line arguments.

**Returns**

`array`: The command line arguments. It does not include the entry script name.

### resolve() <span id="method-resolve"></span>

```php
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.

**Throws**

- [`Exception`](/docs/api/yii/console/exception/index.md): when parameter is wrong and can not be resolved

### setParams() <span id="method-setParams"></span>

```php
public function setParams(array $params): mixed
```

Sets the command line arguments.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$params` | `array` | The command line arguments |

**Returns**

`mixed`