Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Container Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy vs. reuse for dependency wiring. The decision is rarely "should we adopt a container" — it is "which container, and where." This package is a candidate only for the narrow slot of framework-agnostic PSR-11 resolution, and the real alternative is usually the one already on disk (illuminate/container in any Laravel codebase).
  • Library/package extraction roadmap. If you are pulling domain logic out of a Laravel monolith into a reusable Composer package or an internal SDK, you need a container that does not drag illuminate/* behind it. This package supports that decision: small surface, MIT, PSR-11 interface as the contract.
  • Multi-runtime and non-HTTP surfaces. CLI tools, queue consumers, cron scripts, and small internal microservices that live outside the framework benefit from a ~zero-config container with constructor autowiring and lazy closures.
  • Interoperability as an architectural hedge. Coding against 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.
  • Test infrastructure. A tiny PSR-11 container is a legitimate way to assemble test doubles and fixture graphs without booting a framework.
  • Explicitly not supported: replacing a framework's native container inside a Laravel application. Two containers means two singleton scopes, two autowiring strategies, and a debugging surface where "which container resolved this?" becomes a support ticket. That is a product decision to decline, and it should be written down so it isn't relitigated.
  • Signal read on the score (0.125, 5 stars, 0 dependents). This is a vendor-and-audit candidate, not a strategic dependency. Frame any adoption as a bounded experiment with an exit ramp, not a platform commitment.

When to Consider This Package

Consider it when all of these hold:

  • You need PSR-11 compliance in code that must not depend on Laravel/Symfony.
  • Your binding needs are simple: class/interface registration, singletons vs. transients, closure factories, lazy resolution, constructor autowiring.
  • The dependency footprint matters (edge runtimes, small CLIs, distributed library where transitive deps are the enemy).
  • You are willing to pin an exact version, read the source, and vendor/fork it if it becomes load-bearing.
  • You can express the swap risk as low because all consumers type-hint ContainerInterface.

Look elsewhere when any of these hold:

  • Inside a Laravel app. Use 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.
  • You need contextual/parameterized binding, tagging, method injection, service providers with deferred registration, compiled/optimized containers, or attribute-based injection. Verify against the source — the description does not claim these, so assume absent until proven.
  • You need scale-time performance guarantees or a compiled container (Symfony DI, PHP-DI).
  • You need maintenance assurances: security policy, response SLAs, multiple maintainers, a release cadence, or a community to lean on for edge cases. One maintainer, 5 stars, 0 dependents is a bus-factor of one. Last release June 2024 suggests it is not abandoned but also not actively exercised.
  • You need documentation depth, IDE/static-analysis integration, or a large body of Stack Overflow answers to onboard engineers.
  • A single-instance, short-lived script where 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.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin