# Request

> Request represents a request that is handled by an yii\base\Application.

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

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

2 subclasses:

- [`yii\console\Request`](/docs/api/yii/console/request/index.md)
- [`yii\web\Request`](/docs/api/yii/web/request/index.md)

Request represents a request that is handled by an [`Application`](/docs/api/yii/base/application/index.md).

For more details and usage information on Request, see the [guide article on requests](/docs/guide/runtime-requests/index.md).

## Properties

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

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`Component`](/docs/api/yii/base/component/index.md) |
| [`getIsConsoleRequest()`](#method-getIsConsoleRequest) | Returns a value indicating whether the current request is made via command line. | `Request` |
| [`getScriptFile()`](#method-getScriptFile) | Returns entry script file path. | `Request` |
| <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. | [`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. | [`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. | [`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. | [`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. | [`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. | [`Component`](/docs/api/yii/base/component/index.md) |
| [`resolve()`](#method-resolve) abstract | Resolves the current request into a route and the associated parameters. | `Request` |
| [`setIsConsoleRequest()`](#method-setIsConsoleRequest) | Sets the value indicating whether the current request is made via command line. | `Request` |
| [`setScriptFile()`](#method-setScriptFile) | Sets the entry script file path. | `Request` |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`Component`](/docs/api/yii/base/component/index.md) |

## Method details

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

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

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

```php
public function getScriptFile(): string
```

Returns entry script file path.

**Returns**

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

**Throws**

- [`InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the entry script file path cannot be determined automatically.

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

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

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

```php
public function setIsConsoleRequest(bool $value): mixed
```

Sets 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() <span id="method-setScriptFile"></span>

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

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The entry script file path. This can be either a file path or a [path alias](/docs/guide/concept-aliases/index.md). |

**Returns**

`mixed`

**Throws**

- [`InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the provided entry script file path is invalid.