sergix44/container
A lightweight PSR-11 compatible dependency injection container for PHP, with bindings, singletons, aliases, and automatic constructor resolution. It keeps service wiring simple and testable for small apps and libraries, without requiring a full framework.
illuminate/container in any Laravel codebase).illuminate/* behind it. This package supports that decision: small surface, MIT, PSR-11 interface as the contract.Psr\Container\ContainerInterface rather than a concrete container keeps a later swap to Symfony DI, PHP-DI, or League\Container cheap. Adopting this package is really a decision to standardize on the interface, with this as the current implementation.Consider it when all of these hold:
ContainerInterface.Look elsewhere when any of these hold:
Illuminate\Container. It already provides autowiring, singletons, closures, interface binding, contextual binding, and PSR-11 compliance. Adopting this adds a second resolution path and no capability.new Foo(new Bar()) is genuinely sufficient. Not every problem needs a container; the cheapest container is the one you didn't add.Decision rule to socialize: framework code → native container; extracted/shared code → this package behind ContainerInterface; anything with contextual binding or scale requirements → PHP-DI or Symfony DI.
For executives (30 seconds). We're evaluating a small open-source PHP dependency-injection container as an internal plumbing component for code we're pulling out of the main application into reusable packages. License is MIT, so cost is zero; the code is small enough to audit in an afternoon. It is not a platform bet and not a customer-facing feature — worst case we spend a day evaluating and fall back to the container we already ship. The reason to care is structural: it lets extracted components run in CLI tools and services without dragging the full framework along, which reduces maintenance surface and makes future framework changes cheaper.
For engineering leads. The value proposition is narrow and precise: PSR-11 compliance, singleton/transient lifecycles, closure factories, lazy resolution, constructor autowiring — with no framework coupling. That is exactly the shape of dependency we want in shared libraries, because we program against the interface and can swap the implementation later for a few days of work, not a quarter. The trade-off is maturity: single maintainer, near-zero public adoption, no visible security process. So the recommendation is contained adoption with a fence around it — allowed in extracted packages and standalone services, disallowed as a second container inside Laravel, pinned to an exact version, and covered by integration tests that assert our bindings resolve. If it ever becomes load-bearing for a revenue path, we vendor it into our own namespace and own it. We should also confirm in writing which capabilities we are not getting (contextual binding, tagging, compiled container) so no team quietly assumes them. Success criterion: one extracted package ships with it and the interface, and the swap-out path is demonstrated in a spike. If that doesn't hold, we drop it and use PHP-DI.
How can I help you explore Laravel packages today?