# Action

> Base class for the standalone debugger actions dispatched through yii\debug\Module::$actionMap.

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › [actions](/docs/extensions/debug/reference/actions/index.md) › Action

| class | `yii\debug\actions\Action` |
| --- | --- |
| Extends | [`yii\web\Action`](/docs/api/yii/web/action/index.md) » [`yii\base\Action`](/docs/api/yii/base/action/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\ViewContextInterface`](/docs/api/yii/base/viewcontextinterface/index.md), [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Source | [`src/actions/Action.php`](https://github.com/yii2-extensions/debug/blob/main/src/actions/Action.php#L31) |

8 subclasses:

- [`CompareAction`](/docs/extensions/debug/reference/actions/compareaction/index.md)
- [`DownloadMailAction`](/docs/extensions/debug/reference/actions/downloadmailaction/index.md)
- [`IndexAction`](/docs/extensions/debug/reference/actions/indexaction/index.md)
- [`PhpInfoAction`](/docs/extensions/debug/reference/actions/phpinfoaction/index.md)
- [`ToolbarDataAction`](/docs/extensions/debug/reference/actions/toolbardataaction/index.md)
- [`ViewAction`](/docs/extensions/debug/reference/actions/viewaction/index.md)
- [`yii\debug\actions\db\ExplainAction`](/docs/extensions/debug/reference/actions/db/explainaction/index.md)
- [`yii\debug\actions\queue\JobAction`](/docs/extensions/debug/reference/actions/queue/jobaction/index.md)

Base class for the standalone debugger actions dispatched through [`Module::$actionMap`](/docs/api/yii/base/module/index.md#property-actionMap).

Owns the plumbing the removed debug controller used to provide: typed module access, manifest caching, per-tag
snapshot loading with retries, shared shell-context preparation, layout-wrapped view rendering, and the panel
error view.

## 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-controller"></span>[`$controller`](/docs/api/yii/base/action/index.md#property-controller) | `yii\base\T\|null` | The controller that owns this action, or `null` when the action runs standalone. via [`Module::$actionMap`](/docs/api/yii/base/module/index.md#property-actionMap) Default: `null`. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="property-debugModule"></span>`$debugModule` read-only | [`yii\debug\Module`](/docs/extensions/debug/reference/module/index.md) | Owning debug module. | `Action` |
| <span id="property-id"></span>[`$id`](/docs/api/yii/base/action/index.md#property-id) | `string\|null` | ID of the action; `null` between construction and dispatcher post-assignment for standalone actions resolved through [`Module::$actionMap`](/docs/api/yii/base/module/index.md#property-actionMap) or [`Module::$actionNamespace`](/docs/api/yii/base/module/index.md#property-actionNamespace). Default: `null`. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="property-manifest"></span>`$manifest` read-only | `array<string, PHPForge\Debug\Storage\RequestSummary>` | Manifest entries indexed by tag. | `Action` |
| <span id="property-module"></span>[`$module`](/docs/api/yii/base/action/index.md#property-module) | [`yii\base\Module`](/docs/api/yii/base/module/index.md)`\|null` | The owning module, or `null` if neither a module nor a controller is attached. Available since 22.0. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="property-summary"></span>`$summary` | `PHPForge\Debug\Storage\RequestSummary\|null` | Summary metadata for the active debug entry, populated by [`loadData()`](/docs/extensions/debug/reference/actions/action/index.md#method-loadData). Default: `null`. | `Action` |
| <span id="property-uniqueId"></span>[`$uniqueId`](/docs/api/yii/base/action/index.md#property-uniqueId) read-only | `string` | The unique ID of this action among the whole application. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="property-viewPath"></span>`$viewPath` read-only | `string` | Absolute path to the debugger views. | `Action` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/action/index.md#method-__construct) | Constructor. | [`yii\base\Action`](/docs/api/yii/base/action/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) |
| [`getDebugModule()`](#method-getDebugModule) | Returns the owning debug module. | `Action` |
| [`getManifest()`](#method-getManifest) | Returns the debug entry manifest, reloading it from the log target on demand. | `Action` |
| <span id="method-getModule"></span>[`getModule()`](/docs/api/yii/base/action/index.md#method-getModule) | Returns the module that owns this action when invoked standalone. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="method-getUniqueId"></span>[`getUniqueId()`](/docs/api/yii/base/action/index.md#method-getUniqueId) | Returns the unique ID of this action among the whole application. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| [`getViewPath()`](#method-getViewPath) | Returns the view directory shared by every debugger page. | `Action` |
| <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) |
| [`loadData()`](#method-loadData) | Loads the debug entry for the given tag into every registered panel. | `Action` |
| <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) |
| [`prepareShell()`](#method-prepareShell) | Prepares the shared shell for a request panel or nested panel action. | `Action` |
| [`render()`](#method-render) | Renders a debugger view wrapped in the shared page layout. | `Action` |
| [`renderPartial()`](#method-renderPartial) | Renders a debugger view without the page layout. | `Action` |
| <span id="method-runWithParams"></span>[`runWithParams()`](/docs/api/yii/base/action/index.md#method-runWithParams) | Runs this action with the specified parameters. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| <span id="method-setModule"></span>[`setModule()`](/docs/api/yii/base/action/index.md#method-setModule) | Sets the module that owns this action when invoked standalone. | [`yii\base\Action`](/docs/api/yii/base/action/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) |
| <span id="method-afterRun"></span>[`afterRun()`](/docs/api/yii/base/action/index.md#method-afterRun) protected | This method is called right after `run()` is executed. | [`yii\base\Action`](/docs/api/yii/base/action/index.md) |
| [`beforeRun()`](#method-beforeRun) protected | Forces the HTML response format and installs the bare shell before the action body runs. | `Action` |
| [`createBareShellContext()`](#method-createBareShellContext) protected | Builds the bare shell installed by [`beforeRun()`](/docs/extensions/debug/reference/actions/action/index.md#method-beforeRun) through [`Module::getShellContextFactory()`](/docs/extensions/debug/reference/module/index.md#method-getShellContextFactory). | `Action` |
| [`createPanelRenderContext()`](#method-createPanelRenderContext) protected | Builds the portable state available to shared panel renderers for the active snapshot. | `Action` |
| [`createShellContext()`](#method-createShellContext) protected | Builds the shared shell for an index or view page through [`Module::getShellContextFactory()`](/docs/extensions/debug/reference/module/index.md#method-getShellContextFactory). | `Action` |
| [`getLogTarget()`](#method-getLogTarget) protected | Returns the initialized debug log target. | `Action` |
| [`getMailCollector()`](#method-getMailCollector) protected | Returns the registered mail collector. | `Action` |
| [`getPanel()`](#method-getPanel) protected | Returns a registered panel by ID. | `Action` |
| [`prepareIndexShell()`](#method-prepareIndexShell) protected | Prepares the shared shell for the request history page. | `Action` |
| [`renderPanelError()`](#method-renderPanelError) protected | Renders a JSON-safe panel exception snapshot through Yii's exception view. | `Action` |
| <span id="method-resolveStandaloneParams"></span>[`resolveStandaloneParams()`](/docs/api/yii/web/action/index.md#method-resolveStandaloneParams) protected | Resolves the parameters of `run()` using the same HTTP-aware binder as [`Controller::bindActionParams()`](/docs/api/yii/web/controller/index.md#method-bindActionParams). | [`yii\web\Action`](/docs/api/yii/web/action/index.md) |
| [`resolveTheme()`](#method-resolveTheme) protected | Resolves the effective light or dark theme. | `Action` |

## Method details

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

```php
public function getDebugModule(): yii\debug\Module
```

Returns the owning debug module.

**Returns**

[`yii\debug\Module`](/docs/extensions/debug/reference/module/index.md): Owning debug module.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the action was dispatched without a debug module.

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

```php
public function getManifest(bool $forceReload = false): array<string, PHPForge\Debug\Storage\RequestSummary>
```

Returns the debug entry manifest, reloading it from the log target on demand.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$forceReload` | `bool` | `true` to bypass the in-memory cache and re-read the manifest from disk. |

**Returns**

`array<string, PHPForge\Debug\Storage\RequestSummary>`: Manifest entries indexed by tag.

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

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

Returns the view directory shared by every debugger page.

**Returns**

`string`: Absolute path to the debugger views.

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

```php
public function loadData(string $tag, int $maxRetry = 0): void
```

Loads the debug entry for the given tag into every registered panel.

Retries up to `$maxRetry` times (waiting one second between attempts) because debug data is logged from a PHP
shutdown function whose execution may be delayed (notably when xdebug is enabled).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$tag` | `string` | Tag of the debug entry to load. |
| `$maxRetry` | `int` | Maximum number of retries before giving up. |

**Throws**

- [`yii\web\NotFoundHttpException`](/docs/api/yii/web/notfoundhttpexception/index.md): when the tag cannot be located after every retry, or when the entry lacks a summary block.

**See also**

- <https://github.com/yiisoft/yii2/issues/1504>

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

```php
public function prepareShell(yii\debug\Panel $activePanel, string $tag): void
```

Prepares the shared shell for a request panel or nested panel action.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$activePanel` | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) | Panel focused by the rendered page. |
| `$tag` | `string` | Tag of the loaded debug entry. |

**Throws**

- [`yii\web\NotFoundHttpException`](/docs/api/yii/web/notfoundhttpexception/index.md): when no summary was loaded for the tag.

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

```php
public function render(string $view, array<string, mixed> $params = []): string
```

Renders a debugger view wrapped in the shared page layout.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | `string` | View name relative to [`getViewPath()`](/docs/extensions/debug/reference/actions/action/index.md#method-getViewPath). |
| `$params` | `array<string, mixed>` | View parameters. |

**Returns**

`string`: Rendered page markup.

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

```php
public function renderPartial(string $view, array<string, mixed> $params = []): string
```

Renders a debugger view without the page layout.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | `string` | View name relative to [`getViewPath()`](/docs/extensions/debug/reference/actions/action/index.md#method-getViewPath). |
| `$params` | `array<string, mixed>` | View parameters. |

**Returns**

`string`: Rendered view markup.

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

```php
protected function beforeRun(): mixed
```

Forces the HTML response format and installs the bare shell before the action body runs.

**Returns**

`mixed`

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

```php
protected function createBareShellContext(): yii\debug\widgets\shell\ShellContext
```

Builds the bare shell installed by [`beforeRun()`](/docs/extensions/debug/reference/actions/action/index.md#method-beforeRun) through [`Module::getShellContextFactory()`](/docs/extensions/debug/reference/module/index.md#method-getShellContextFactory).

**Returns**

[`yii\debug\widgets\shell\ShellContext`](/docs/extensions/debug/reference/widgets/shell/shellcontext/index.md): Shell that echoes raw content without the brand bar or sidebar.

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

```php
protected function createPanelRenderContext(yii\debug\Panel $panel, string $tag): PHPForge\Debug\Panel\PanelRenderContext
```

Builds the portable state available to shared panel renderers for the active snapshot.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$panel` | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) | Panel being rendered. |
| `$tag` | `string` | Capture under inspection. |

**Returns**

`PHPForge\Debug\Panel\PanelRenderContext`: State shared with the portable renderers.

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

```php
protected function createShellContext(string $mode, array<string, PHPForge\Debug\Storage\RequestSummary> $manifest, string|null $activeTag, PHPForge\Debug\Storage\RequestSummary|null $summary, PHPForge\Debug\View\Sidebar\SidebarView $sidebar): yii\debug\widgets\shell\ShellContext
```

Builds the shared shell for an index or view page through [`Module::getShellContextFactory()`](/docs/extensions/debug/reference/module/index.md#method-getShellContextFactory).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$mode` | `string` | One of the [`ShellContext`](/docs/extensions/debug/reference/widgets/shell/shellcontext/index.md) mode constants. |
| `$manifest` | `array<string, PHPForge\Debug\Storage\RequestSummary>` | Manifest entries indexed by tag. |
| `$activeTag` | `string\|null` | Tag focused by the page, or `null` on the index. |
| `$summary` | `PHPForge\Debug\Storage\RequestSummary\|null` | Summary of the focused entry, or `null` on the index. |
| `$sidebar` | `PHPForge\Debug\View\Sidebar\SidebarView` | Prepared sidebar payload. |

**Returns**

[`yii\debug\widgets\shell\ShellContext`](/docs/extensions/debug/reference/widgets/shell/shellcontext/index.md): Shell for the requested page.

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

```php
protected function getLogTarget(): yii\debug\LogTarget
```

Returns the initialized debug log target.

**Returns**

[`yii\debug\LogTarget`](/docs/extensions/debug/reference/logtarget/index.md): Log target used to read the manifest and per-tag panel payloads.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the module was not bootstrapped before the action is used.

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

```php
protected function getMailCollector(): yii\debug\collectors\MailCollector
```

Returns the registered mail collector.

**Returns**

[`yii\debug\collectors\MailCollector`](/docs/extensions/debug/reference/collectors/mailcollector/index.md): Mail collector used to resolve captured mail files.

**Throws**

- [`yii\web\NotFoundHttpException`](/docs/api/yii/web/notfoundhttpexception/index.md): when no mail collector is registered on the module.

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

```php
protected function getPanel(string $id): yii\debug\Panel
```

Returns a registered panel by ID.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `string` | Panel ID to resolve. |

**Returns**

[`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md): Panel instance matching the given ID.

**Throws**

- [`yii\web\NotFoundHttpException`](/docs/api/yii/web/notfoundhttpexception/index.md): when the module has no panel registered under the given ID.

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

```php
protected function prepareIndexShell(array<string, PHPForge\Debug\Storage\RequestSummary> $manifest, string $cursor): void
```

Prepares the shared shell for the request history page.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$manifest` | `array<string, PHPForge\Debug\Storage\RequestSummary>` | Manifest entries indexed by tag. |
| `$cursor` | `string` | Active history-cursor tag, or `''` when none is selected. |

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

```php
protected function renderPanelError(PHPForge\Debug\Storage\ExceptionSnapshot $error): string
```

Renders a JSON-safe panel exception snapshot through Yii's exception view.

`ErrorHandler::renderFile()` accepts mixed params, so the immutable exception snapshot can use the view's
duck-typed `$exception` slot without recreating or executing the original throwable.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$error` | `PHPForge\Debug\Storage\ExceptionSnapshot` | Exception captured by the panel, typically via [`Panel::getError()`](/docs/extensions/debug/reference/panel/index.md#method-getError). |

**Returns**

`string`: Rendered exception view body.

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

```php
protected function resolveTheme(): string
```

Resolves the effective light or dark theme.

**Returns**

`string`: Effective theme: `'light'` or `'dark'`.