sanmai/di-container
A straightforward PSR-11 dependency injection container with zero-configuration autowiring. It resolves constructor dependencies via reflection, reuses created objects, maps interfaces to concrete implementations, and supports builder objects for complex construction.
Architecture fit
Illuminate\Container — it competes with it.sanmai/di-container as the application container is effectively a framework replacement, not a library adoption. That is out of scope for a product decision.illuminate/*. The author's stated motivation (Infection's own wiring) is the same shape of problem.Integration feasibility
Psr\Container\ContainerInterface and let Laravel pass its own container — which already satisfies PSR-11. In that pattern, sanmai/di-container is unnecessary. It adds value only when a component must supply a working default container for non-Laravel consumers.Technical risk
0.1.x. Semver permits breaking changes in minor bumps; we have already seen iterative churn in set()/bind()/inject() and type-annotation relaxations across 0.1.6–0.1.12. Pin exactly and be prepared to fork.DIContainer\Container; internal notes reference Sanmai\DI\Container. Resolve the real namespace from the tag before any spike — a mismatch here signals documentation drift we will be debugging against.Builder template for static analysis, and a PHPBench suite. Engineering hygiene is better than the star count implies.Key questions
Illuminate\Container or a plain Psr\Container\ContainerInterface type-hint does not?Stack fit
Illuminate\Container. Do not register it in a service provider, do not alias it to ContainerInterface in the app, and do not inject it into controllers or jobs — doing so makes it reachable from framework-managed code and invites two competing graphs.Migration path
Illuminate\* imports, introduce a composition root wired with sanmai/di-container, and expose the module to Laravel via a thin adapter that lets Laravel's container satisfy the module's ContainerInterface dependency.Builder interface rather than closures — builders get constructor injection, are independently testable, and keep the container configuration declarative.Compatibility
Psr\Container\ContainerInterface and remain swappable.Sequencing
ContainerInterface; make sanmai/di-container the default used only when no container is provided.Illuminate\Container. This is the only Laravel-aware code, and it stays ours.Maintenance
composer.json constraints as 0.1.x with a lockfile and a documented upgrade owner.Builder template catches return-type drift at CI time rather than at container resolution time.Support
Scaling
inject()-provided instances persist for the worker's lifetime. Any service holding request-scoped state — authenticated user, correlation ID, request payload, open transaction — will leak across jobs and requests. This must be an explicit design rule or the pilot will fail in a way that is hard to diagnose.Failure modes
Ramp-up
get, set, bind, inject, Builder), so mechanical onboarding is under a day for a mid-level engineer.How can I help you explore Laravel packages today?