Skip to content
PHP Ecosystem
Explore

ToolbarRenderer

API reference › Debug › ToolbarRenderer

final readonly classyii\debug\ToolbarRenderer
Sourcesrc/ToolbarRenderer.php

Renders shared toolbar views and resolves their assets through Yii2.

MethodDescriptionDefined by
__construct()Binds toolbar rendering to the Yii view, asset publisher and template path.ToolbarRenderer
inject()Injects toolbar markup immediately before the final closing body tag.ToolbarRenderer
renderElement()Renders the framework-neutral toolbar template through the Yii2 view component.ToolbarRenderer
scriptTag()Renders a script tag for the Yii2-published toolbar runtime.ToolbarRenderer
public function __construct(yii\base\View $view, yii\web\AssetManager $assetManager, string $viewPath)

Binds toolbar rendering to the Yii view, asset publisher and template path.

Parameters

ParameterTypeDescription
$viewyii\base\ViewYii2 PHP view renderer.
$assetManageryii\web\AssetManagerYii2 asset publisher.
$viewPathstringShared toolbar template path or alias.
public function inject(string $html, string $toolbar): string

Injects toolbar markup immediately before the final closing body tag.

Parameters

ParameterTypeDescription
$htmlstringResponse HTML.
$toolbarstringRendered toolbar markup.

Returns

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

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

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

Parameters

ParameterTypeDescription
$dataUrlstringToolbar payload URL.
$skipUrlslist<string>Same-origin URLs excluded from AJAX tracking.
$positionstringInitial toolbar position.
$heightintInitial drawer height percentage.

Returns

string: Rendered toolbar custom element.

public function scriptTag(): string

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

Emits type="module" so the ES-module chunk keeps its own top-level scope and cannot collide with host-page globals or other classic scripts.

Returns

string: Toolbar runtime script tag.