-
-
Notifications
You must be signed in to change notification settings - Fork 3
API reference
Greg Bowler edited this page Apr 12, 2026
·
1 revision
This page is a compact reference for the public API of the library.
For walkthroughs and examples, use the earlier pages in the guide.
bindValue(mixed $value, null|string|Element $context = null): voidbindKeyValue(string $key, mixed $value, null|string|Element $context = null): voidbindData(mixed $kvp, null|string|Element $context = null): voidbindTable(mixed $tableData, null|string|Element $context = null, ?string $bindKey = null): voidbindList(iterable $listData, null|string|Element $context = null, ?string $templateName = null): intbindListCallback(iterable $listData, callable $callback, null|string|Element $context = null, ?string $templateName = null): intcleanupDocument(): void
ComponentBinder exposes the same binding methods as DocumentBinder, but confines all binding to one expanded component element.
Most binding methods accept:
-
nullfor the whole document or whole component - an
Elementinstance - a selector
string
If the selector string does not match, DomTemplate throws ContextElementNotFoundException.
Suitable for bindValue and bindKeyValue:
- strings
- integers
- floats
- booleans
-
Stringableobjects - callables returning a bindable value
Suitable for bindData:
- associative arrays
- objects with public properties
- objects with
#[Bind]or#[BindGetter] - objects with
asArray()
Suitable for bindList and bindListCallback:
- arrays
IteratorIteratorAggregateArrayIterator- iterable objects
Suitable for bindTable:
- row-oriented arrays with a heading row
- associative row lists
- heading => value-list maps
- double-header structures
- traversable equivalents
ComponentExpander::expand(?Element $context = null): arrayPartialExpander::expand(?Element $context = null, ?DocumentBinder $binder = null): arrayPartialContent::getContent(string $name, string $extension = "html", ?string $src = null): stringPartialContent::getHTMLDocument(string $name): HTMLDocument
data-bind:*data-listdata-templatedata-bind:listdata-bind:tabledata-table-keydata-rebinddata-elementdata-bind-debugdata-list-keep-templatedata-partial
ContextElementNotFoundExceptionIncompatibleBindDataExceptionInvalidBindPropertyExceptionListElementNotFoundInContextExceptionIncorrectTableDataFormatTableElementNotFoundInContextExceptionComponentDoesNotContainContextExceptionPartialContentDirectoryNotFoundExceptionPartialContentFileNotFoundExceptionPartialInjectionPointNotFoundExceptionPartialInjectionMultiplePointExceptionCommentIniInvalidDocumentLocationExceptionCyclicRecursionException
That is the end of the main guide. If you want to jump back into the walkthrough flow, return to Home.
PHP.GT/DomTemplate is a separately maintained component of PHP.GT/WebEngine.