Skip to content

PhpRenderer

A renderer produces the output as defined by a View

class PhpRenderer extends Renderer implements IReusableRenderer

ExtendsRenderer
ImplementsIReusableRenderer
Since1.0.0
SourceRenderer/PhpRenderer.php
MethodDescription
getStarterTemplate(): stringReturns the skeleton PHP template written for a newly scaffolded view.
[`render(TemplateLayer $layer, array<string, mixed> &$attributes = [], array<string, mixed> &$slots = [], array<intstring, mixed> &$moreAssigns = []): string`](#render)
reset(): voidClears the per-render state held for the template being included.

public function getStarterTemplate(): string

Returns the skeleton PHP template written for a newly scaffolded view.

The echoed expression follows the renderer’s current variable configuration: a bare $title when extract_vars is on, otherwise the title key of the configured template variable. The value is escaped in the template itself, since a plain PHP template has no auto-escaping.

Returns string

public function render(TemplateLayer $layer, array<string, mixed> &$attributes = [], array<string, mixed> &$slots = [], array<int|string, mixed> &$moreAssigns = []): string

Render the presentation and return the result.

Associative array of additional assigns.

ParameterTypeDescription
$layerTemplateLayerThe template layer to render.
$attributesarray``<``string``, ``mixed``>The template variables.
$slotsarray``<``string``, ``mixed``>The slots.
$moreAssigns`array<int“string, mixed>`

Returns string — A rendered result.

public function reset(): void

Clears the per-render state held for the template being included.

Only the layer, attributes, slots and more-assigns are dropped; the parent reset is deliberately not invoked, so the renderer’s configured variable names, extraction flag and assigns survive for the next render.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
getContext()RendererRetrieve the current application context.
getDefaultExtension()RendererGet the template file extension
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
initialize()RendererInitialize this Renderer.
removeParameter()ParameterHolderRemove a parameter.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.