The Game Panel Design record
The Game Panel
ADR-0004 Accepted

The container does not implement PSR-11

Created
Decided
Versions
History

Context

PSR-11 defines a common container interface: get() and has(), keyed by a string identifier. Its value is interchangeability. A project can swap one container for another, and a component written against the interface can be reused with any container that implements it.

The panel is a bespoke, purpose-built system distributed as a single binary, not a framework. Nobody swaps its container out, and nothing integrates with the panel at the level of its container.

Decision

The container does not implement PSR-11. Callers describe what they want to resolve or invoke with the container's own Resolution and Invocation objects, not with a string identifier passed to get(), and no part of the panel depends on the Psr\Container interfaces.

Alternatives

Implementing PSR-11, alongside the container's own API, which is the option this decision rejects. The interchangeability it provides does not apply to a bespoke system shipped as a single binary. The PSRs are also dated, and implementing one forces a design into its shape, where the container is instead free to be shaped around what the panel needs.

Whether it was weighed at the time, or simply never adopted, is not recorded, and no other alternative appears in the record.

Consequences

Easier:

  • The container's API follows the panel's needs. A resolution carries its name, qualifier, arguments, and whether it is lazy or liminal as part of the request, rather than encoding them in an identifier.

Harder:

  • A library that expects a PSR-11 container cannot be given the panel's container.

Constrained:

  • Components depend on the container's own API, and on nothing from PSR-11.

Sources

  • Commit bdc32d7, "Initial dependency injection work", : the first code of the container, without PSR-11, which is created.
  • PR #23, feat(container): Dependency Injection, merged : the container merged without PSR-11, which is decided. When the decision was taken is not recorded.
  • The decision and its reasons, that PSR-11's interchangeability does not apply to a bespoke system shipped as a single binary and that PSRs are dated and constrain design: first written down on .
  • Issue #31, Engine - Config - TOML, original text of in its edit history: the first written record of the panel being distributed as a binary, two days after this decision's date.
  • composer.json at 728ad64: no dependency on psr/container.

Source adr/0004-the-container-does-not-implement-psr-11.md · commit 072385a · exported