Skip to content

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.

Main binding methods

DocumentBinder

  • bindValue(mixed $value, null|string|Element $context = null): void
  • bindKeyValue(string $key, mixed $value, null|string|Element $context = null): void
  • bindData(mixed $kvp, null|string|Element $context = null): void
  • bindTable(mixed $tableData, null|string|Element $context = null, ?string $bindKey = null): void
  • bindList(iterable $listData, null|string|Element $context = null, ?string $templateName = null): int
  • bindListCallback(iterable $listData, callable $callback, null|string|Element $context = null, ?string $templateName = null): int
  • cleanupDocument(): void

ComponentBinder

ComponentBinder exposes the same binding methods as DocumentBinder, but confines all binding to one expanded component element.

Context arguments

Most binding methods accept:

  • null for the whole document or whole component
  • an Element instance
  • a selector string

If the selector string does not match, DomTemplate throws ContextElementNotFoundException.

Data shapes

Values

Suitable for bindValue and bindKeyValue:

  • strings
  • integers
  • floats
  • booleans
  • Stringable objects
  • callables returning a bindable value

Key/value data

Suitable for bindData:

  • associative arrays
  • objects with public properties
  • objects with #[Bind] or #[BindGetter]
  • objects with asArray()

Lists

Suitable for bindList and bindListCallback:

  • arrays
  • Iterator
  • IteratorAggregate
  • ArrayIterator
  • iterable objects

Tables

Suitable for bindTable:

  • row-oriented arrays with a heading row
  • associative row lists
  • heading => value-list maps
  • double-header structures
  • traversable equivalents

Composition helpers

  • ComponentExpander::expand(?Element $context = null): array
  • PartialExpander::expand(?Element $context = null, ?DocumentBinder $binder = null): array
  • PartialContent::getContent(string $name, string $extension = "html", ?string $src = null): string
  • PartialContent::getHTMLDocument(string $name): HTMLDocument

Key HTML attributes

  • data-bind:*
  • data-list
  • data-template
  • data-bind:list
  • data-bind:table
  • data-table-key
  • data-rebind
  • data-element
  • data-bind-debug
  • data-list-keep-template
  • data-partial

Common exceptions

  • ContextElementNotFoundException
  • IncompatibleBindDataException
  • InvalidBindPropertyException
  • ListElementNotFoundInContextException
  • IncorrectTableDataFormat
  • TableElementNotFoundInContextException
  • ComponentDoesNotContainContextException
  • PartialContentDirectoryNotFoundException
  • PartialContentFileNotFoundException
  • PartialInjectionPointNotFoundException
  • PartialInjectionMultiplePointException
  • CommentIniInvalidDocumentLocationException
  • CyclicRecursionException

That is the end of the main guide. If you want to jump back into the walkthrough flow, return to Home.

Clone this wiki locally