Download the PHP package waffle-commons/container without Composer
On this page you can find all versions of the php package waffle-commons/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download waffle-commons/container
More information about waffle-commons/container
Files in waffle-commons/container
Package container
Short Description PSR-11 dependency-injection container for Waffle Commons: autowiring, singleton lifecycles, and per-request reset semantics for resident-worker mode.
License MIT
Informations about the package container
Waffle Container Component
Release:
0.1.0-beta6|CHANGELOG.mdPSR Compliance: PSR-11 (Psr\Container\ContainerInterface)
A strict PSR-11 service container with reflection-based autowiring, circular-dependency detection, and worker-mode resettability. Core services (the PSR-11 ContainerInterface itself) are locked from override after registration.
π¦ Installation
π§± Surface
| Class | Role |
|---|---|
Waffle\Commons\Container\Container |
The container. Implements Waffle\Commons\Contracts\Container\ContainerInterface (PSR-11 + ResettableInterface). |
Waffle\Commons\Container\Autowire |
Reflection-based autowiring helper used by Container::build() to resolve constructor parameters. |
Waffle\Commons\Container\Exception\ContainerException |
Thrown for retrieval / resolution failures. |
Waffle\Commons\Container\Exception\NotFoundException |
Thrown when get($id) cannot resolve the identifier. |
π Usage
The exact public signature, verbatim from Waffle\Commons\Contracts\Container\ContainerInterface:
π Worker-mode reset
Container implements ResettableInterface. After each request, the kernel calls reset() so the container drops its instance cache while keeping the registered definitions, preventing user-context leaks across FrankenPHP worker requests.
π‘οΈ Locked core services
The constant Container::CORE_SERVICES lists identifiers that must not be redefined once registered. The PSR-11 ContainerInterface itself is in that list β any attempt to override it after the container is built throws ContainerException.
π Circular-dependency detection
Container::get($id) tracks the resolution stack in $resolving and throws ContainerException if a cycle is detected before infinite recursion can occur.
π PHP 8.5 features used
final class Containerβ no subclassing.- Typed properties throughout.
- Typed constants for service registries:
private const CORE_SERVICES = [...];. #[\Override]on every method that overrides PSR-11.
π§ Architectural boundary (mago guard)
An active dependency perimeter is enforced on every CI run by vendor/bin/mago guard (bundled into composer mago; zero baselines). The rules live in mago.toml under [guard.perimeter] β a forbidden use statement fails the build, not a reviewer.
Production code under Waffle\Commons\Container may depend only on:
Waffle\Commons\Container\**β itselfWaffle\Commons\Contracts\**β the shared contracts package, the only Waffle dependency permittedPsr\**β PSR interfaces (PSR-11)@global+Psl\**β PHP core and the PHP Standard Library
Test code under WaffleTests\Commons\Container is unrestricted (@all). Structural rules are guarded too: interfaces must be named *Interface, Exception\** classes must end in *Exception, and any Enum\** namespace may hold only enum declarations.
Contract-first, component-agnostic by construction: components compose through waffle-commons/contracts, never directly through one another.
π§ͺ Testing
π Documentation
Full guides live in the central DiΓ‘taxis documentation tree:
π License
MIT β see LICENSE.md.