Binding Diagnostics

Overview of bindings.md and the provenance log

When an Injector is created with an explicit writable directory, Ray.Di records how the container was composed and writes bindings.md into that directory.

$injector = new Injector(new AppModule(), $tmpDir); // writes $tmpDir/bindings.md

The file lists the resolved bindings, the modules that composed them, and a provenance log of what happened during composition:

  • bind — a binding was registered
  • replace — a later binding replaced an earlier one (for example via override())
  • keep — a later binding for the same key was discarded
  • move — a binding was renamed

Entries that lost a collision are shown as discarded, so you can see which binding actually won.

Writing is best-effort and atomic: diagnostics never break injection, and an unchanged binding surface is not rewritten.

HTML viewer

The ray/bindings package renders bindings.md as an interactive HTML page with an object graph.

composer require --dev ray/bindings
vendor/bin/bindings-html var/tmp/bindings.md composer.lock > bindings.html

bindings.html: object graph, summary, and binding list

BEAR.Sunday applications can generate the same page with the bindings format of BEAR.ApiDoc.

Note: the Ray\Bindings\* classes and bin/bindings-html that shipped in 2.22.1–2.22.2 moved out of core in 2.23.0. The package above is their continuation.