Trace
API reference › Debug Core › Helper › Trace
Renders captured argument-free source frames as configurable, escaped source links.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
create() static | Creates a renderer emitting DEFAULT_TEMPLATE links without path rewriting. | Trace |
render() | Renders one source frame, or an escaped dump when file or line is missing. | Trace |
withPathMappings() | Returns a copy rewriting containerized or remote source paths to their local counterparts. | Trace |
withTemplate() | Returns a copy rendering every frame with the given template. | Trace |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
DEFAULT_TEMPLATE | '<a href="ide://open?url=file://{file}&line={line}">{text}</a>' | Default template: an ide:// deep link IDE extensions resolve into “open file at line”. | Trace |
Method details
Section titled “Method details”create()
Section titled “create() ”public static function create(): selfCreates a renderer emitting DEFAULT_TEMPLATE links without path rewriting.
Returns
self: Renderer using the default template and no path mappings.
render()
Section titled “render() ”public function render(array<string, mixed> $frame): stringRenders one source frame, or an escaped dump when file or line is missing.
Internal PHP functions such as call_user_func() may produce frames without those keys, see
https://www.php.net/manual/en/function.debug-backtrace.php#59713.
Parameters
| Parameter | Type | Description |
|---|---|---|
$frame | array<string, | Source frame; consumes file, line, and the optional text label. |
Returns
string: Rendered source line.
withPathMappings()
Section titled “withPathMappings() ”public function withPathMappings(array<array-key, mixed> $pathMappings): selfReturns a copy rewriting containerized or remote source paths to their local counterparts.
Entries whose value does not coerce to a string are dropped; both sides are normalized to forward slashes and a single trailing slash, and only the first matching prefix is applied.
Parameters
| Parameter | Type | Description |
|---|---|---|
$pathMappings | array<array-key, | Remote source-path prefixes mapped to local prefixes. |
Returns
self: New instance rewriting frame paths through the normalized mappings.
withTemplate()
Section titled “withTemplate() ”public function withTemplate(Closure(array<string, mixed>): mixed|string|false $template): selfReturns a copy rendering every frame with the given template.
Parameters
| Parameter | Type | Description |
|---|---|---|
$template | Closure(array<string, | Placeholder template resolving {file}, {line}, and {text} against the escaped frame values, false to emit escaped plain text without a link, or a closure receiving the frame with the normalized file, line, and text keys; a string returned by the closure resolves the same placeholders, any other result renders as an escaped dump. |
Returns
self: New instance rendering every frame with the given template.