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

The container does Do not implement PSR-11

Comparing
v1 to v2
Current
Read the document

Context

PSR-11 defines a common is PHP's shared container interface: get() and has(), each keyed by a string identifier. Its value What it offers is interchangeability. A project An application can swap one container for another, and a component library written against the interface can be reused interface works with any container that implements it.

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

Decision

The container does I will not implement PSR-11. Callers Code that wants something from the container will describe what they want to resolve or invoke it with the container's own Resolutions own resolution and Invocationinvocation objects, not with objects rather than a string identifier passed passed to get(), and no part of the panel depends panel will depend on the Psr\Container interfaces.

Alternatives

Implementing PSR-11, alongside the container's own API, which is so that a library written against the option this decision rejectsinterface could be handed the panel's container. The I rejected this because interchangeability it provides does not apply to buys nothing in a bespoke system shipped as as a single binary. The PSRs are also also dated, and implementing one forces bends a design into its shape, where the container is can instead free to be shaped around around what the panel needs.

Whether it this 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 will follow what the panel's panel needs. A resolution carries resolution will carry its name, , qualifier, arguments, and whether whether it is lazy or liminal liminal as part part of the request, rather than encoding packing them in an identifierinto a string.

Harder:

  • A library that expects a PSR-11 container cannot will not be given able to use the panel's containers.

Constrained:

  • Components will 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-no-psr-11.md · commit 9444a99 · published