laminas/laminas-servicemanager
Laminas ServiceManager is a PSR-11 compatible dependency injection container for PHP. It supports factory-based service creation, aliases, abstract factories, delegators, and lazy loading, making it a flexible foundation for managing object dependencies.
Architecture fit. This is not a Laravel package; it is the Laminas (formerly Zend Framework) factory-driven DI container and the reference implementation of the Service Locator pattern, PSR-11 compatible via container-interop. Laravel already ships Illuminate\Container\Container plus the service-provider lifecycle, facades, and contextual binding, all of which assume a single container. Introducing Laminas\ServiceManager into a Laravel app creates a second, parallel container with its own configuration vocabulary (factories, abstract_factories, delegators, aliases, shared_by_default), its own exception hierarchy, and its own resolution order. The architecture fit is therefore poor for greenfield Laravel work and acceptable only when a specific dependency mandates it — most commonly a Laminas/Mezzio component, an MVC module, or a plugin-manager-based library that type-hints ContainerInterface and expects factory-configured services.
Integration feasibility. Technically feasible with modest effort. Because both containers satisfy PSR-11, a bridge is straightforward: register a Laminas\ServiceManager\ServiceManager as a singleton in a Laravel service provider, populate it with delegator factories that resolve back through Laravel's container, and expose the reverse via a Psr\Container\ContainerInterface binding. Plugin managers (subclasses of AbstractPluginManager with $instanceOf validation) are genuinely useful for homogeneous object families — validators, formatters, handlers — where Laravel has no first-class equivalent. The ReflectionBasedAbstractFactory / ConfigAbstractFactory / generate-factory-for-class toolchain is a credible developer-experience story for teams already fluent in Laminas.
Technical risk. Medium. The dominant risk is the dual-container anti-pattern: circular dependencies that span both containers are difficult to diagnose, scoped and singleton lifetimes become ambiguous, and tests must bootstrap two graphs. Secondary risks: abstract factories impose O(n) discovery cost per lookup (explicit docs warning), lazy services require ocramius/proxy-manager or equivalent and add an AOP-style proxy layer that obscures stack traces, and the package's release cadence is tied to Laminas's volunteer maintainership rather than Laravel's. Stars (~160) and the reported zero dependents are low signal for a component this foundational, so adoption decisions must rest on direct inspection rather than ecosystem gravity.
Key questions.
Stack fit. Register the ServiceManager once, as a singleton, behind a narrow interface — never inject it directly into controllers or jobs. Service providers should own its construction and configuration; application code should continue to type-hint concrete classes or interfaces resolved by Laravel. Treat Laminas as an implementation detail of the one vendor library that needs it.
Migration path. Sequence it as containment rather than adoption: (1) identify the exact service names the third-party library requests; (2) register only those in the Laminas container, using InvokableFactory or small closures that delegate to Laravel's container for shared dependencies (DB, config, logger); (3) bridge the reverse direction so the library can resolve Laravel-managed services; (4) forbid new application services from being registered in the Laminas container. If we later drop the dependency, the container disappears with it.
Compatibility. BSD-3-Clause is permissive and compatible with Laravel's MIT ecosystem; no licensing friction. PSR-11 and container-interop interfaces are stable and already present transitively in most Laravel installs, so the surface area is small. The real compatibility question is PHP version support versus our runtime matrix — pin the release and verify against the actual Laravel version in production, since this component's support window is set by Laminas, not by Laravel's release train.
Sequencing. Spike first: one engineer, one week, prove the bridge resolves the target library end-to-end with tests. Then land the adapter behind a feature flag in a single service provider with a documented boundary. Then migrate call sites that currently use app() or facades in the affected area. Only after that consider whether plugin managers are worth standardizing for our own homogeneous service families — and default to no unless a concrete case exists.
Maintenance. Two dependency graphs to patch, two changelogs to watch, two sets of security advisories. Laminas publishes advisories through its own channels; we must subscribe or we will miss them. Budget for a quarterly review of both containers, and expect upgrade work to arrive on Laminas's schedule, uncorrelated with Laravel's.
Support. No Laravel-specific documentation, no Stack Overflow corpus for the bridge, and no vendor. Internal runbooks must be written by whoever builds the adapter — that person becomes the de facto owner. Document the resolution order and the "which container owns what" rules explicitly; this is the single highest-value artifact.
Scaling. Container resolution cost is negligible at request scale for explicit factory maps. The risk is configuration growth: abstract factories slow every lookup linearly, and a container with many abstract factories plus many delegators becomes opaque at debug time. Cap the number of registered abstract factories and prefer explicit maps in production, per the package's own guidance.
Failure modes. Watch for: InvalidServiceException from plugin-manager $instanceOf validation surfacing as 500s if unhandled; infinite recursion when delegators resolve back into Laravel services that depend on the Laminas container; missing proxy-manager causing lazy-service failures only on code paths that touch the proxy; and silent divergences where a service is registered in both containers and one instance wins. Each of these should have a targeted test.
Ramp-up. Expect one to two weeks for a mid-level Laravel developer to become productive with Laminas idioms — factory vs. abstract factory vs. delegator, plugin managers, and the v2-to-v3 container semantics. That is real cost against a container Laravel developers already know. Recommend at most one or two designated owners rather than team-wide upskilling, and keep the blast radius small enough that the knowledge is never load-bearing.
How can I help you explore Laravel packages today?