# ToolbarRenderer

> Renders shared toolbar views and resolves their assets through Yii3.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Web](/docs/extensions/yii3-debug/reference/web/index.md) › ToolbarRenderer

| final readonly class | `Yii3\Debug\Web\ToolbarRenderer` |
| --- | --- |
| Source | [`src/Web/ToolbarRenderer.php`](https://github.com/yii3/debug/blob/main/src/Web/ToolbarRenderer.php#L18) |

Renders shared toolbar views and resolves their assets through Yii3.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a toolbar renderer with Yii3 view and asset services. | `ToolbarRenderer` |
| [`inject()`](#method-inject) | Injects toolbar markup immediately before the final closing body tag. | `ToolbarRenderer` |
| [`render()`](#method-render) | Renders the shared toolbar element and the Yii3-published runtime. | `ToolbarRenderer` |
| [`renderElement()`](#method-renderElement) | Renders the framework-neutral toolbar template through the Yii3 view component. | `ToolbarRenderer` |
| [`scriptTag()`](#method-scriptTag) | Renders a script tag for the Yii3-published toolbar runtime. | `ToolbarRenderer` |

## Method details

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

```php
public function __construct(Yiisoft\View\WebView $view, Yiisoft\Assets\AssetManager $assetManager, string $viewPath)
```

Creates a toolbar renderer with Yii3 view and asset services.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | `Yiisoft\View\WebView` | Yii3 PHP view renderer. |
| `$assetManager` | `Yiisoft\Assets\AssetManager` | Yii3 asset publisher. |
| `$viewPath` | `string` | Resolved path containing the shared debugger templates. |

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

```php
public function inject(string $html, string $toolbar): string
```

Injects toolbar markup immediately before the final closing body tag.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$html` | `string` | Response HTML. |
| `$toolbar` | `string` | Rendered toolbar markup. |

**Returns**

`string`: HTML containing the toolbar, appended when no closing body tag exists.

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

```php
public function render(string $dataUrl, list<string> $skipUrls = [], string $position = 'bottom', int $height = 50): string
```

Renders the shared toolbar element and the Yii3-published runtime.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$dataUrl` | `string` | Toolbar payload URL. |
| `$skipUrls` | `list<string>` | Same-origin URLs excluded from AJAX tracking. |
| `$position` | `string` | Initial toolbar position. |
| `$height` | `int` | Initial drawer height percentage. |

**Returns**

`string`: Toolbar element followed by its published runtime tag.

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

```php
public function renderElement(string $dataUrl, list<string> $skipUrls = [], string $position = 'bottom', int $height = 50): string
```

Renders the framework-neutral toolbar template through the Yii3 view component.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$dataUrl` | `string` | Toolbar payload URL. |
| `$skipUrls` | `list<string>` | Same-origin URLs excluded from AJAX tracking. |
| `$position` | `string` | Initial toolbar position. |
| `$height` | `int` | Initial drawer height percentage. |

**Returns**

`string`: Rendered toolbar custom element.

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

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

Renders a script tag for the Yii3-published toolbar runtime.

**Returns**

`string`: Toolbar runtime script tag.